Skip to content

Commit be4662e

Browse files
author
vrana
committed
Convert setCaption() to safe HTML
Test Plan: /settings/panel/display/ Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2432 Differential Revision: https://secure.phabricator.com/D4824
1 parent bcf9b9d commit be4662e

15 files changed

+52
-45
lines changed

src/applications/auth/controller/PhabricatorLoginController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ public function processRequest() {
177177
id(new AphrontFormPasswordControl())
178178
->setLabel(pht('Password'))
179179
->setName('password')
180-
->setCaption(
181-
'<a href="/login/email/">'.
182-
pht('Forgot your password? / Email Login').'</a>'));
180+
->setCaption(hsprintf(
181+
'<a href="/login/email/">%s</a>',
182+
pht('Forgot your password? / Email Login'))));
183183

184184
if ($require_captcha) {
185185
$form->appendChild(

src/applications/conduit/controller/PhabricatorConduitConsoleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function processRequest() {
9797
id(new AphrontFormTextControl())
9898
->setLabel($param)
9999
->setName("params[{$param}]")
100-
->setCaption(phutil_escape_html($desc)));
100+
->setCaption($desc));
101101
}
102102

103103
$form

src/applications/countdown/controller/PhabricatorCountdownEditController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ public function processRequest() {
9797
->setLabel('End date')
9898
->setValue($display_datepoint)
9999
->setName('datepoint')
100-
->setCaption(
100+
->setCaption(hsprintf(
101101
'Examples: '.
102102
'<tt>2011-12-25</tt> or '.
103103
'<tt>3 hours</tt> or '.
104-
'<tt>June 8 2011, 5 PM</tt>.'))
104+
'<tt>June 8 2011, 5 PM</tt>.')))
105105
->appendChild(
106106
id(new AphrontFormSubmitControl())
107107
->addCancelButton('/countdown/')

src/applications/directory/controller/PhabricatorDirectoryMainController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ private function buildNeedsTriagePanel(array $projects) {
149149

150150
$panel = new AphrontPanelView();
151151
$panel->setHeader('Needs Triage');
152-
$panel->setCaption(
152+
$panel->setCaption(hsprintf(
153153
'Open tasks with "Needs Triage" priority in '.
154-
'<a href="/project/">projects you are a member of</a>.');
154+
'<a href="/project/">projects you are a member of</a>.'));
155155

156156
$panel->addButton(
157157
phutil_tag(

src/applications/files/controller/PhabricatorFileUploadController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private function renderUploadLimit() {
9999
$limit = phabricator_parse_bytes($limit);
100100
if ($limit) {
101101
$formatted = phabricator_format_bytes($limit);
102-
return 'Maximum file size: '.phutil_escape_html($formatted);
102+
return 'Maximum file size: '.$formatted;
103103
}
104104

105105
$doc_href = PhabricatorEnv::getDocLink(
@@ -112,7 +112,7 @@ private function renderUploadLimit() {
112112
),
113113
'Configuring File Upload Limits');
114114

115-
return 'Upload limit is not configured, see '.$doc_link.'.';
115+
return hsprintf('Upload limit is not configured, see %s.', $doc_link);
116116
}
117117

118118
}

src/applications/maniphest/controller/ManiphestReportController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,13 @@ public function renderBurn() {
245245

246246
if ($handle) {
247247
$header = "Task Burn Rate for Project ".$handle->renderLink();
248-
$caption = "<p>NOTE: This table reflects tasks <em>currently</em> in ".
249-
"the project. If a task was opened in the past but added to ".
250-
"the project recently, it is counted on the day it was ".
251-
"opened, not the day it was categorized. If a task was part ".
252-
"of this project in the past but no longer is, it is not ".
253-
"counted at all.</p>";
248+
$caption = hsprintf(
249+
"<p>NOTE: This table reflects tasks <em>currently</em> in ".
250+
"the project. If a task was opened in the past but added to ".
251+
"the project recently, it is counted on the day it was ".
252+
"opened, not the day it was categorized. If a task was part ".
253+
"of this project in the past but no longer is, it is not ".
254+
"counted at all.</p>");
254255
} else {
255256
$header = "Task Burn Rate for All Tasks";
256257
$caption = null;

src/applications/maniphest/controller/ManiphestTaskEditController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,9 @@ public function processRequest() {
478478
$email_create = PhabricatorEnv::getEnvConfig(
479479
'metamta.maniphest.public-create-email');
480480
if (!$task->getID() && $email_create) {
481-
$email_hint = pht('You can also create tasks by sending an email to: ').
482-
'<tt>'.phutil_escape_html($email_create).'</tt>';
481+
$email_hint = pht(
482+
'You can also create tasks by sending an email to: %s',
483+
phutil_tag('tt', array(), $email_create));
483484
$description_control->setCaption($email_hint);
484485
}
485486

src/applications/metamta/controller/PhabricatorMetaMTAReceiveController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ public function processRequest() {
5757
id(new AphrontFormTextControl())
5858
->setLabel(pht('To'))
5959
->setName('obj')
60-
->setCaption(pht('e.g. <tt>D1234</tt> or <tt>T1234</tt>')))
60+
->setCaption(pht(
61+
'e.g. %s or %s',
62+
phutil_tag('tt', array(), 'D1234'),
63+
phutil_tag('tt', array(), 'T1234'))))
6164
->appendChild(
6265
id(new AphrontFormTextAreaControl())
6366
->setLabel(pht('Body'))

src/applications/metamta/controller/PhabricatorMetaMTASendController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ public function processRequest() {
116116
id(new AphrontFormTextControl())
117117
->setLabel(pht('Mail Tags'))
118118
->setName('mailtags')
119-
->setCaption(
120-
pht('Example:').' <tt>differential-cc, differential-comment</tt>'))
119+
->setCaption(pht(
120+
'Example: %s',
121+
phutil_tag('tt', array(), 'differential-cc, differential-comment'))
122+
))
121123
->appendChild(
122124
id(new AphrontFormDragAndDropUploadControl())
123125
->setLabel(pht('Attach Files'))
@@ -144,8 +146,7 @@ public function processRequest() {
144146
'1',
145147
pht('Send immediately. (Do not enqueue for daemons.)'),
146148
PhabricatorEnv::getEnvConfig('metamta.send-immediately'))
147-
->setCaption(pht('Daemons can be started with %s.', $phdlink))
148-
)
149+
->setCaption(pht('Daemons can be started with %s.', $phdlink)))
149150
->appendChild(
150151
id(new AphrontFormSubmitControl())
151152
->setValue(pht('Send Mail')));

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ public function processRequest() {
150150
->setLabel('Custom Domain')
151151
->setName('custom_domain')
152152
->setValue($blog->getDomain())
153-
->setCaption('Must include at least one dot (.), e.g. '.
154-
'blog.example.com')
153+
->setCaption('Must include at least one dot (.), e.g. blog.example.com')
155154
->setError($e_custom_domain)
156155
)
157156
->appendChild(

src/applications/repository/controller/PhabricatorRepositoryArcanistProjectEditController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public function processRequest() {
8383
id(new AphrontFormTextControl())
8484
->setLabel('Indexed Languages')
8585
->setName('symbolIndexLanguages')
86-
->setCaption('Separate with commas, for example: <tt>php, py</tt>')
86+
->setCaption(
87+
hsprintf('Separate with commas, for example: <tt>php, py</tt>'))
8788
->setValue($langs))
8889
->appendChild(
8990
id(new AphrontFormTokenizerControl())

src/applications/repository/controller/PhabricatorRepositoryEditController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ private function processTrackingRequest() {
456456
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
457457
->setValue($repository->getDetail('ssh-key'))
458458
->setError($e_ssh_key)
459-
->setCaption('Specify the entire private key, <em>or</em>...'))
459+
->setCaption(
460+
hsprintf('Specify the entire private key, <em>or</em>...')))
460461
->appendChild(
461462
id(new AphrontFormTextControl())
462463
->setName('ssh-keyfile')
@@ -552,10 +553,10 @@ private function processTrackingRequest() {
552553
->setName('branch-filter')
553554
->setLabel('Track Only')
554555
->setValue($branch_filter_str)
555-
->setCaption(
556+
->setCaption(hsprintf(
556557
'Optional list of branches to track. Other branches will be '.
557558
'completely ignored. If left empty, all branches are tracked. '.
558-
'Example: <tt>master, release</tt>'));
559+
'Example: <tt>master, release</tt>')));
559560
}
560561

561562
$inset
@@ -651,7 +652,7 @@ private function processTrackingRequest() {
651652
->setName('uuid')
652653
->setLabel('UUID')
653654
->setValue($repository->getUUID())
654-
->setCaption('Repository UUID from <tt>svn info</tt>.'));
655+
->setCaption(hsprintf('Repository UUID from <tt>svn info</tt>.')));
655656
}
656657

657658
$form->appendChild($inset);

src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function helloWorld() {
6767
'User Guide: Configuring an External Editor');
6868

6969
$font_default = PhabricatorEnv::getEnvConfig('style.monospace');
70-
$font_default = phutil_escape_html($font_default);
7170

7271
$pref_monospaced_textareas_value = $preferences
7372
->getPreference($pref_monospaced_textareas);
@@ -97,11 +96,11 @@ function helloWorld() {
9796
id(new AphrontFormTextControl())
9897
->setLabel('Editor Link')
9998
->setName($pref_editor)
100-
->setCaption(
99+
->setCaption(hsprintf(
101100
'Link to edit files in external editor. '.
102-
'%f is replaced by filename, %l by line number, %r by repository '.
103-
'callsign, %% by literal %. '.
104-
"For documentation, see {$editor_doc_link}.")
101+
'%%f is replaced by filename, %%l by line number, %%r by repository '.
102+
'callsign, %%%% by literal %%. For documentation, see %s.',
103+
$editor_doc_link))
105104
->setValue($preferences->getPreference($pref_editor)))
106105
->appendChild(
107106
id(new AphrontFormSelectControl())
@@ -116,9 +115,10 @@ function helloWorld() {
116115
id(new AphrontFormTextControl())
117116
->setLabel('Monospaced Font')
118117
->setName($pref_monospaced)
119-
->setCaption(
118+
->setCaption(hsprintf(
120119
'Overrides default fonts in tools like Differential.<br />'.
121-
'(Default: '.$font_default.')')
120+
'(Default: %s)',
121+
$font_default))
122122
->setValue($preferences->getPreference($pref_monospaced)))
123123
->appendChild(
124124
id(new AphrontFormMarkupControl())

src/view/form/control/AphrontFormControl.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ final public function render() {
140140
}
141141

142142
if (strlen($this->getCaption())) {
143-
$caption =
144-
'<div class="aphront-form-caption">'.
145-
$this->getCaption().
146-
'</div>';
143+
$caption = phutil_tag(
144+
'div',
145+
array('class' => 'aphront-form-caption'),
146+
$this->getCaption());
147147
} else {
148148
$caption = null;
149149
}

src/view/layout/AphrontPanelView.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ public function render() {
6969
}
7070

7171
if ($this->caption !== null) {
72-
$caption =
73-
'<div class="aphront-panel-view-caption">'.
74-
$this->caption.
75-
'</div>';
72+
$caption = phutil_tag(
73+
'div',
74+
array('class' => 'aphront-panel-view-caption'),
75+
$this->caption);
7676
} else {
7777
$caption = null;
7878
}

0 commit comments

Comments
 (0)