Skip to content

Commit 58b6e2c

Browse files
author
vrana
committed
Convert AphrontDialogView to safe HTML
Summary: Done by searching for `AphrontDialogView` and then `appendChild()`. Also added some `pht()`. Test Plan: None. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4882
1 parent e4736bf commit 58b6e2c

File tree

32 files changed

+152
-153
lines changed

32 files changed

+152
-153
lines changed

src/aphront/configuration/AphrontDefaultApplicationConfiguration.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function handleException(Exception $ex) {
227227
phlog($ex);
228228

229229
$class = get_class($ex);
230-
$message = phutil_escape_html($ex->getMessage());
230+
$message = $ex->getMessage();
231231

232232
if ($ex instanceof AphrontQuerySchemaException) {
233233
$message .=
@@ -243,11 +243,13 @@ public function handleException(Exception $ex) {
243243
$trace = null;
244244
}
245245

246-
$content =
246+
$content = hsprintf(
247247
'<div class="aphront-unhandled-exception">'.
248-
'<div class="exception-message">'.$message.'</div>'.
249-
$trace.
250-
'</div>';
248+
'<div class="exception-message">%s</div>'.
249+
'%s'.
250+
'</div>',
251+
$message,
252+
$trace);
251253

252254
$dialog = new AphrontDialogView();
253255
$dialog
@@ -349,7 +351,7 @@ private function renderStackTrace($trace, PhabricatorUser $user) {
349351
}
350352
$file_name = $file_name.' : '.(int)$part['line'];
351353
} else {
352-
$file_name = '<em>(Internal)</em>';
354+
$file_name = phutil_tag('em', array(), '(Internal)');
353355
}
354356

355357

@@ -376,11 +378,12 @@ private function renderStackTrace($trace, PhabricatorUser $user) {
376378
'wide',
377379
));
378380

379-
return
381+
return hsprintf(
380382
'<div class="exception-trace">'.
381383
'<div class="exception-trace-header">Stack Trace</div>'.
382-
$table->render().
383-
'</div>';
384+
'%s',
385+
'</div>',
386+
phutil_safe_html($table->render()));
384387
}
385388

386389
}

src/applications/auth/controller/PhabricatorLDAPLoginController.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ public function processRequest() {
4343
$dialog = new AphrontDialogView();
4444
$dialog->setUser($current_user);
4545
$dialog->setTitle(pht('Already Linked to Another Account'));
46-
$dialog->appendChild(
47-
'<p>'.pht('The LDAP account you just authorized is already '.
46+
$dialog->appendChild(phutil_tag('p', array(), pht(
47+
'The LDAP account you just authorized is already '.
4848
'linked toanother Phabricator account. Before you can link it '.
4949
'to a different LDAP account, you must unlink the old '.
50-
'account.').'</p>'
51-
);
50+
'account.')));
5251
$dialog->addCancelButton('/settings/panel/ldap/');
5352

5453
return id(new AphrontDialogResponse())->setDialog($dialog);
@@ -62,10 +61,8 @@ public function processRequest() {
6261
$dialog = new AphrontDialogView();
6362
$dialog->setUser($current_user);
6463
$dialog->setTitle(pht('Link LDAP Account'));
65-
$dialog->appendChild(
66-
'<p>'.
67-
pht('Link your LDAP account to your Phabricator account?').
68-
'</p>');
64+
$dialog->appendChild(phutil_tag('p', array(), pht(
65+
'Link your LDAP account to your Phabricator account?')));
6966
$dialog->addHiddenInput('username', $request->getStr('username'));
7067
$dialog->addHiddenInput('password', $request->getStr('password'));
7168
$dialog->addSubmitButton(pht('Link Accounts'));

src/applications/auth/controller/PhabricatorLDAPUnlinkController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public function processRequest() {
1818
$dialog = new AphrontDialogView();
1919
$dialog->setUser($user);
2020
$dialog->setTitle(pht('Really unlink account?'));
21-
$dialog->appendChild(
22-
'<p>'.pht('You will not be able to login using this account '.
23-
'once you unlink it. Continue?').'</p>');
21+
$dialog->appendChild(phutil_tag('p', array(), pht(
22+
'You will not be able to login using this account '.
23+
'once you unlink it. Continue?')));
2424
$dialog->addSubmitButton(pht('Unlink Account'));
2525
$dialog->addCancelButton('/settings/panel/ldap/');
2626

src/applications/auth/controller/PhabricatorLoginController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function processRequest() {
2929
$dialog = new AphrontDialogView();
3030
$dialog->setUser($user);
3131
$dialog->setTitle(pht('Login Required'));
32-
$dialog->appendChild('<p>'.pht('You must login to continue.').'</p>');
32+
$dialog->appendChild(phutil_tag('p', array(), pht(
33+
'You must login to continue.')));
3334
$dialog->addSubmitButton(pht('Login'));
3435
$dialog->addCancelButton('/', pht('Cancel'));
3536

src/applications/auth/controller/PhabricatorLogoutController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public function processRequest() {
4646
$dialog = id(new AphrontDialogView())
4747
->setUser($user)
4848
->setTitle(pht('Log out of Phabricator?'))
49-
->appendChild('<p>'.pht('Are you sure you want to log out?').'</p>')
49+
->appendChild(phutil_tag('p', array(), pht(
50+
'Are you sure you want to log out?')))
5051
->addSubmitButton(pht('Logout'))
5152
->addCancelButton('/');
5253

src/applications/auth/controller/PhabricatorOAuthLoginController.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,9 @@ public function processRequest() {
116116
$dialog = new AphrontDialogView();
117117
$dialog->setUser($current_user);
118118
$dialog->setTitle(pht('Link %s Account', $provider_name));
119-
$dialog->appendChild(
120-
pht(
121-
'<p>Link your %s account to your Phabricator account?</p>',
122-
phutil_escape_html($provider_name)));
119+
$dialog->appendChild(phutil_tag('p', array(), pht(
120+
'Link your %s account to your Phabricator account?',
121+
$provider_name)));
123122
$dialog->addHiddenInput('confirm_token', $provider->getAccessToken());
124123
$dialog->addHiddenInput('expires', $oauth_info->getTokenExpires());
125124
$dialog->addHiddenInput('state', $this->oauthState);

src/applications/auth/controller/PhabricatorOAuthUnlinkController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public function processRequest() {
3434
$dialog = new AphrontDialogView();
3535
$dialog->setUser($user);
3636
$dialog->setTitle(pht('Really unlink account?'));
37-
$dialog->appendChild(
38-
'<p>'.pht('You will not be able to login using this account '.
39-
'once you unlink it. Continue?').'</p>');
37+
$dialog->appendChild(phutil_tag('p', array(), pht(
38+
'You will not be able to login using this account '.
39+
'once you unlink it. Continue?')));
4040
$dialog->addSubmitButton(pht('Unlink Account'));
4141
$dialog->addCancelButton($provider->getSettingsPanelURI());
4242

src/applications/daemon/controller/PhabricatorWorkerTaskUpdateController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ public function processRequest() {
7272
case 'retry':
7373
if ($can_retry) {
7474
$dialog->setTitle('Really retry task?');
75-
$dialog->appendChild(
76-
'<p>The task will be put back in the queue and executed '.
77-
'again.</p>');
75+
$dialog->appendChild(phutil_tag('p', array(), pht(
76+
'The task will be put back in the queue and executed again.')));
7877
$dialog->addSubmitButton('Retry Task');
7978
} else {
8079
$dialog->setTitle('Can Not Retry');

src/applications/differential/controller/DifferentialCommentSaveController.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ public function processRequest() {
6060

6161
if (strlen($comment) || $has_inlines) {
6262
$dialog->addSubmitButton(pht('Post as Comment'));
63-
$dialog->appendChild('<br />');
64-
$dialog->appendChild(
65-
'<p>'.pht('Do you want to post your feedback anyway, as a normal '.
66-
'comment?').'</p>');
63+
$dialog->appendChild(phutil_tag('br'));
64+
$dialog->appendChild(phutil_tag('p', array(), pht(
65+
'Do you want to post your feedback anyway, as a normal comment?')));
6766
}
6867

6968
return id(new AphrontDialogResponse())->setDialog($dialog);

src/applications/differential/controller/DifferentialSubscribeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function processRequest() {
4343
$dialog
4444
->setUser($user)
4545
->setTitle($title)
46-
->appendChild('<p>'.$prompt.'</p>')
46+
->appendChild(phutil_tag('p', array(), $prompt))
4747
->setSubmitURI($request->getRequestURI())
4848
->addSubmitButton($button)
4949
->addCancelButton('/D'.$revision->getID());

0 commit comments

Comments
 (0)