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());

src/applications/drydock/controller/DrydockLeaseReleaseController.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public function processRequest() {
2424
$dialog = id(new AphrontDialogView())
2525
->setUser($user)
2626
->setTitle(pht('Lease Not Active'))
27-
->appendChild(
28-
'<p>'.pht('You can only release "active" leases.').'</p>')
27+
->appendChild(phutil_tag('p', array(), pht(
28+
'You can only release "active" leases.')))
2929
->addCancelButton($lease_uri);
3030

3131
return id(new AphrontDialogResponse())->setDialog($dialog);
@@ -35,11 +35,10 @@ public function processRequest() {
3535
$dialog = id(new AphrontDialogView())
3636
->setUser($user)
3737
->setTitle(pht('Really release lease?'))
38-
->appendChild(
39-
'<p>'.pht(
40-
'Releasing a lease may cause trouble for the lease holder and '.
41-
'trigger cleanup of the underlying resource. It can not be '.
42-
'undone. Continue?').'</p>')
38+
->appendChild(phutil_tag('p', array(), pht(
39+
'Releasing a lease may cause trouble for the lease holder and '.
40+
'trigger cleanup of the underlying resource. It can not be '.
41+
'undone. Continue?')))
4342
->addSubmitButton(pht('Release Lease'))
4443
->addCancelButton($lease_uri);
4544

src/applications/drydock/controller/DrydockResourceCloseController.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public function processRequest() {
2424
$dialog = id(new AphrontDialogView())
2525
->setUser($user)
2626
->setTitle(pht('Resource Not Open'))
27-
->appendChild(
28-
'<p>'.pht('You can only close "open" resources.').'</p>')
27+
->appendChild(phutil_tag('p', array(), pht(
28+
'You can only close "open" resources.')))
2929
->addCancelButton($resource_uri);
3030

3131
return id(new AphrontDialogResponse())->setDialog($dialog);
@@ -35,10 +35,9 @@ public function processRequest() {
3535
$dialog = id(new AphrontDialogView())
3636
->setUser($user)
3737
->setTitle(pht('Really close resource?'))
38-
->appendChild(
39-
'<p>'.pht(
40-
'Closing a resource releases all leases and destroys the '.
41-
'resource. It can not be undone. Continue?').'</p>')
38+
->appendChild(phutil_tag('p', array(), pht(
39+
'Closing a resource releases all leases and destroys the '.
40+
'resource. It can not be undone. Continue?')))
4241
->addSubmitButton(pht('Close Resource'))
4342
->addCancelButton($resource_uri);
4443

src/applications/help/controller/PhabricatorHelpKeyboardShortcutController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public function processRequest() {
3737
));
3838
}
3939

40-
$table =
41-
'<table class="keyboard-shortcut-help">'.
42-
implode('', $rows).
43-
'</table>';
40+
$table = phutil_tag(
41+
'table',
42+
array('class' => 'keyboard-shortcut-help'),
43+
$rows);
4444

4545
$dialog = id(new AphrontDialogView())
4646
->setUser($user)

src/applications/macro/controller/PhabricatorMacroDisableController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public function processRequest() {
4343
$dialog
4444
->setUser($request->getUser())
4545
->setTitle(pht('Really disable macro?'))
46-
->appendChild(
47-
'<p>'.pht('Really disable the much-beloved image macro %s? '.
48-
'It will be sorely missed.', phutil_escape_html($macro->getName())).
49-
'</p>')
46+
->appendChild(phutil_tag('p', array(), pht(
47+
'Really disable the much-beloved image macro %s? '.
48+
'It will be sorely missed.',
49+
$macro->getName())))
5050
->setSubmitURI($this->getApplicationURI('/disable/'.$this->id.'/'))
5151
->addSubmitButton(pht('Disable'))
5252
->addCancelButton($view_uri);

src/applications/maniphest/controller/ManiphestExportController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function processRequest() {
2828
$dialog->setUser($user);
2929

3030
$dialog->setTitle('Excel Export Not Configured');
31-
$dialog->appendChild(
31+
$dialog->appendChild(hsprintf(
3232
'<p>This system does not have PHPExcel installed. This software '.
3333
'component is required to export tasks to Excel. Have your system '.
3434
'administrator install it from:</p>'.
@@ -38,7 +38,7 @@ public function processRequest() {
3838
'</p>'.
3939
'<br />'.
4040
'<p>Your PHP "include_path" needs to be updated to include the '.
41-
'PHPExcel Classes/ directory.</p>');
41+
'PHPExcel Classes/ directory.</p>'));
4242

4343
$dialog->addCancelButton('/maniphest/');
4444
return id(new AphrontDialogResponse())->setDialog($dialog);
@@ -59,8 +59,8 @@ public function processRequest() {
5959
$dialog->setUser($user);
6060

6161
$dialog->setTitle('Export Tasks to Excel');
62-
$dialog->appendChild(
63-
'<p>Do you want to export the query results to Excel?</p>');
62+
$dialog->appendChild(phutil_tag('p', array(), pht(
63+
'Do you want to export the query results to Excel?')));
6464

6565
$dialog->addCancelButton('/maniphest/');
6666
$dialog->addSubmitButton('Export to Excel');

src/applications/oauthserver/controller/client/PhabricatorOAuthClientDeleteController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ public function processRequest() {
3737
$dialog = new AphrontDialogView();
3838
$dialog->setUser($current_user);
3939
$dialog->setTitle($title);
40-
$dialog->appendChild(
41-
'<p>Are you sure you want to delete this client?</p>'
42-
);
40+
$dialog->appendChild(phutil_tag('p', array(), pht(
41+
'Are you sure you want to delete this client?')));
4342
$dialog->addSubmitButton();
4443
$dialog->addCancelButton($client->getEditURI());
4544
return id(new AphrontDialogResponse())->setDialog($dialog);

src/applications/oauthserver/controller/clientauthorization/PhabricatorOAuthClientAuthorizationDeleteController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ public function processRequest() {
4646
$dialog = new AphrontDialogView();
4747
$dialog->setUser($current_user);
4848
$dialog->setTitle($title);
49-
$dialog->appendChild(
50-
'<p>Are you sure you want to delete this client authorization?</p>'
51-
);
49+
$dialog->appendChild(phutil_tag('p', array(), pht(
50+
'Are you sure you want to delete this client authorization?')));
5251
$dialog->addSubmitButton();
5352
$dialog->addCancelButton($authorization->getEditURI());
5453
return id(new AphrontDialogResponse())->setDialog($dialog);

src/applications/phame/controller/blog/PhameBlogDeleteController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function processRequest() {
4141
->appendChild(
4242
pht(
4343
'Really delete the blog "%s"? It will be gone forever.',
44-
phutil_escape_html($blog->getName())))
44+
$blog->getName()))
4545
->addSubmitButton(pht('Delete'))
4646
->addCancelButton($cancel_uri);
4747

src/applications/phame/controller/post/PhamePostDeleteController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function processRequest() {
4141
->appendChild(
4242
pht(
4343
'Really delete the post "%s"? It will be gone forever.',
44-
phutil_escape_html($post->getTitle())))
44+
$post->getTitle()))
4545
->addSubmitButton(pht('Delete'))
4646
->addCancelButton($cancel_uri);
4747

src/applications/phame/controller/post/PhamePostNotLiveController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ public function processRequest() {
2525

2626
$reasons = array();
2727
if (!$post->getBlog()) {
28-
$reasons[] =
29-
'<p>'.pht('You can not view the live version of this post because it '.
28+
$reasons[] = phutil_tag('p', array(), pht(
29+
'You can not view the live version of this post because it '.
3030
'is not associated with a blog. Move the post to a blog in order to '.
31-
'view it live.').'</p>';
31+
'view it live.'));
3232
}
3333

3434
if ($post->isDraft()) {
35-
$reasons[] =
36-
'<p>'.pht('You can not view the live version of this post because it '.
37-
'is still a draft. Use "Preview/Publish" to publish the post.').'</p>';
35+
$reasons[] = phutil_tag('p', array(), pht(
36+
'You can not view the live version of this post because it '.
37+
'is still a draft. Use "Preview/Publish" to publish the post.'));
3838
}
3939

4040
if ($reasons) {

src/applications/phame/controller/post/PhamePostUnpublishController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function processRequest() {
4545
pht(
4646
'The post "%s" will no longer be visible to other users until you '.
4747
'republish it.',
48-
phutil_escape_html($post->getTitle())))
48+
$post->getTitle()))
4949
->addSubmitButton(pht('Unpublish'))
5050
->addCancelButton($cancel_uri);
5151

src/applications/phriction/controller/PhrictionEditController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public function processRequest() {
108108
$dialog = new AphrontDialogView();
109109
$dialog->setUser($user);
110110
$dialog->setTitle(pht('No Edits'));
111-
$dialog->appendChild(
112-
'<p>'.pht('You did not make any changes to the document.').'</p>');
111+
$dialog->appendChild(phutil_tag('p', array(), pht(
112+
'You did not make any changes to the document.')));
113113
$dialog->addCancelButton($request->getRequestURI());
114114

115115
return id(new AphrontDialogResponse())->setDialog($dialog);
@@ -122,8 +122,8 @@ public function processRequest() {
122122
$dialog = new AphrontDialogView();
123123
$dialog->setUser($user);
124124
$dialog->setTitle(pht('Empty Page'));
125-
$dialog->appendChild(
126-
'<p>'.pht('You can not create an empty document.').'</p>');
125+
$dialog->appendChild(phutil_tag('p', array(), pht(
126+
'You can not create an empty document.')));
127127
$dialog->addCancelButton($request->getRequestURI());
128128

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

src/applications/ponder/controller/PonderAnswerSaveController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public function processRequest() {
2323
$dialog = new AphrontDialogView();
2424
$dialog->setUser($request->getUser());
2525
$dialog->setTitle('Empty answer');
26-
$dialog->appendChild('<p>Your answer must not be empty.</p>');
26+
$dialog->appendChild(phutil_tag('p', array(), pht(
27+
'Your answer must not be empty.')));
2728
$dialog->addCancelButton('/Q'.$question_id);
2829

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

0 commit comments

Comments
 (0)