1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00

Return safe HTML from all render()

Summary:
This is pretty brutal and it adds some `phutil_safe_html()`.
But it is a big step in the right direction.

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2432

Differential Revision: https://secure.phabricator.com/D4905
This commit is contained in:
vrana 2013-02-11 13:16:57 -08:00
parent 37b98450a5
commit c9ab1fe505
48 changed files with 389 additions and 382 deletions

View file

@ -26,7 +26,7 @@ final class Aphront403Response extends AphrontHTMLResponse {
}
$failure = new AphrontRequestFailureView();
$failure->setHeader('403 Forbidden');
$failure->appendChild('<p>'.$forbidden_text.'</p>');
$failure->appendChild(phutil_tag('p', array(), $forbidden_text));
$view = new PhabricatorStandardPageView();
$view->setTitle('403 Forbidden');

View file

@ -12,7 +12,8 @@ final class Aphront404Response extends AphrontHTMLResponse {
public function buildResponseString() {
$failure = new AphrontRequestFailureView();
$failure->setHeader('404 Not Found');
$failure->appendChild('<p>The page you requested was not found.</p>');
$failure->appendChild(phutil_tag('p', array(), pht(
'The page you requested was not found.')));
$view = new PhabricatorStandardPageView();
$view->setTitle('404 Not Found');

View file

@ -16,8 +16,8 @@ final class PhabricatorDisabledUserController
$failure_view = new AphrontRequestFailureView();
$failure_view->setHeader(pht('Account Disabled'));
$failure_view->appendChild(
'<p>'.pht('Your account has been disabled.').'</p>');
$failure_view->appendChild(phutil_tag('p', array(), pht(
'Your account has been disabled.')));
return $this->buildStandardPageResponse(
$failure_view,

View file

@ -98,10 +98,8 @@ EOBODY;
$view = new AphrontRequestFailureView();
$view->setHeader(pht('Check Your Email'));
$view->appendChild(
'<p>'.pht(
'An email has been sent with a link you can use to login.'
).'</p>');
$view->appendChild(phutil_tag('p', array(), pht(
'An email has been sent with a link you can use to login.')));
return $this->buildStandardPageResponse(
$view,
array(

View file

@ -50,17 +50,16 @@ final class PhabricatorEmailTokenController
$view = new AphrontRequestFailureView();
$view->setHeader(pht('Unable to Login'));
$view->appendChild(
'<p>'.pht('The authentication information in the link you clicked is '.
$view->appendChild(phutil_tag('p', array(), pht(
'The authentication information in the link you clicked is '.
'invalid or out of date. Make sure you are copy-and-pasting the '.
'entire link into your browser. You can try again, or request '.
'a new email.').'</p>');
$view->appendChild(
'a new email.')));
$view->appendChild(hsprintf(
'<div class="aphront-failure-continue">'.
'<a class="button" href="/login/email/">'.
pht('Send Another Email').
'</a>'.
'</div>');
'<a class="button" href="/login/email/">%s</a>'.
'</div>',
pht('Send Another Email')));
return $this->buildStandardPageResponse(
$view,

View file

@ -49,14 +49,16 @@ final class PhabricatorLoginValidateController
$view = new AphrontRequestFailureView();
$view->setHeader(pht('Login Failed'));
$view->appendChild(
'<p>'.pht('Login failed:').'</p>'.
$list.
'<p>'.pht('<strong>Clear your cookies</strong> and try again.').'</p>');
$view->appendChild(
$view->appendChild(hsprintf(
'<p>%s</p>%s<p>%s</p>',
pht('Login failed:'),
$list,
pht('<strong>Clear your cookies</strong> and try again.')));
$view->appendChild(hsprintf(
'<div class="aphront-failure-continue">'.
'<a class="button" href="/login/">'.pht('Try Again').'</a>'.
'</div>');
'<a class="button" href="/login/">%s</a>'.
'</div>',
pht('Try Again')));
return $this->buildStandardPageResponse(
$view,
array(

View file

@ -41,31 +41,26 @@ final class PhabricatorMustVerifyEmailController
$error_view = new AphrontRequestFailureView();
$error_view->setHeader(pht('Check Your Email'));
$error_view->appendChild(
'<p>'.
pht('You must verify your email address to login. You should have a new '.
$error_view->appendChild(phutil_tag('p', array(), pht(
'You must verify your email address to login. You should have a new '.
'email message from Phabricator with verification instructions in your '.
'inbox (%s).', phutil_tag('strong', array(), $email_address)).
'</p>');
$error_view->appendChild(
'<p>'.
pht('If you did not receive an email, you can click the button below '.
'to try sending another one.').
'</p>');
$error_view->appendChild(
'<div class="aphront-failure-continue">'.
phabricator_form(
$user,
'inbox (%s).', phutil_tag('strong', array(), $email_address))));
$error_view->appendChild(phutil_tag('p', array(), pht(
'If you did not receive an email, you can click the button below '.
'to try sending another one.')));
$error_view->appendChild(hsprintf(
'<div class="aphront-failure-continue">%s</div>',
phabricator_form(
$user,
array(
'action' => '/login/mustverify/',
'method' => 'POST',
),
phutil_tag(
'button',
array(
'action' => '/login/mustverify/',
'method' => 'POST',
),
phutil_tag(
'button',
array(
),
pht('Send Another Email'))).
'</div>');
pht('Send Another Email')))));
return $this->buildApplicationPage(

View file

@ -77,11 +77,12 @@ final class PhabricatorOAuthFailureView extends AphrontView {
$provider_name);
}
$view->appendChild(
$view->appendChild(hsprintf(
'<div class="aphront-failure-continue">'.
$diagnose.
'<a href="/login/" class="button">'.pht('Continue').'</a>'.
'</div>');
'%s<a href="/login/" class="button">%s</a>'.
'</div>',
$diagnose,
pht('Continue')));
return $view->render();
}

View file

@ -48,9 +48,10 @@ final class AphrontCalendarMonthView extends AphrontView {
$markup = array();
$empty_box =
'<div class="aphront-calendar-day aphront-calendar-empty">'.
'</div>';
$empty_box = phutil_tag(
'div',
array('class' => 'aphront-calendar-day aphront-calendar-empty'),
'');
for ($ii = 0; $ii < $empty; $ii++) {
$markup[] = $empty_box;
@ -79,9 +80,10 @@ final class AphrontCalendarMonthView extends AphrontView {
} else {
$show_events = array_fill_keys(
array_keys($show_events),
'<div class="aphront-calendar-event aphront-calendar-event-empty">'.
'&nbsp;'.
'</div>');
hsprintf(
'<div class="aphront-calendar-event aphront-calendar-event-empty">'.
'&nbsp;'.
'</div>'));
}
foreach ($events as $event) {
@ -110,31 +112,32 @@ final class AphrontCalendarMonthView extends AphrontView {
$name);
}
$markup[] =
'<div class="'.$class.'">'.
'<div class="aphront-calendar-date-number">'.
$day_number.
'</div>'.
$holiday_markup.
implode("\n", $show_events).
'</div>';
$markup[] = hsprintf(
'<div class="%s">'.
'<div class="aphront-calendar-date-number">%s</div>'.
'%s%s'.
'</div>',
$class,
$day_number,
$holiday_markup,
phutil_implode_html("\n", $show_events));
}
$table = array();
$rows = array_chunk($markup, 7);
foreach ($rows as $row) {
$table[] = '<tr>';
$table[] = hsprintf('<tr>');
while (count($row) < 7) {
$row[] = $empty_box;
}
foreach ($row as $cell) {
$table[] = '<td>'.$cell.'</td>';
$table[] = phutil_tag('p', array(), $cell);
}
$table[] = '</tr>';
$table[] = hsprintf('</tr>');
}
$table =
$table = hsprintf(
'<table class="aphront-calendar-view">'.
$this->renderCalendarHeader($first).
'%s'.
'<tr class="aphront-calendar-day-of-week-header">'.
'<th>Sun</th>'.
'<th>Mon</th>'.
@ -144,8 +147,10 @@ final class AphrontCalendarMonthView extends AphrontView {
'<th>Fri</th>'.
'<th>Sat</th>'.
'</tr>'.
implode("\n", $table).
'</table>';
'%s'.
'</table>',
$this->renderCalendarHeader($first),
phutil_implode_html("\n", $table));
return $table;
}
@ -176,16 +181,15 @@ final class AphrontCalendarMonthView extends AphrontView {
"\xE2\x86\x92"
);
$left_th = '<th>'.$prev_link.'</th>';
$right_th = '<th>'.$next_link.'</th>';
$left_th = phutil_tag('th', array(), $prev_link);
$right_th = phutil_tag('th', array(), $next_link);
}
return
'<tr class="aphront-calendar-month-year-header">'.
$left_th.
'<th colspan="'.$colspan.'">'.$date->format('F Y').'</th>'.
$right_th.
'</tr>';
return hsprintf(
'<tr class="aphront-calendar-month-year-header">%s%s%s</tr>',
$left_th,
phutil_tag('th', array('colspan' => $colspan), $date->format('F Y')),
$right_th);
}
private function getNextYearAndMonth() {

View file

@ -386,14 +386,15 @@ final class DifferentialRevisionViewController extends DifferentialController {
$page_pane = id(new DifferentialPrimaryPaneView())
->setID($pane_id)
->appendChild(
$comment_view->render().
$diff_history->render().
$warning.
$local_view->render().
$toc_view->render().
$other_view.
$changeset_view->render());
->appendChild(array(
$comment_view->render(),
$diff_history->render(),
$warning,
$local_view->render(),
$toc_view->render(),
$other_view,
$changeset_view->render(),
));
if ($comment_form) {
$page_pane->appendChild($comment_form->render());
}
@ -857,13 +858,12 @@ final class DifferentialRevisionViewController extends DifferentialController {
$handles = $this->loadViewerHandles($phids);
$view->setHandles($handles);
return
return hsprintf(
'%s<div class="differential-panel">%s</div>',
id(new PhabricatorHeaderView())
->setHeader(pht('Open Revisions Affecting These Files'))
->render().
'<div class="differential-panel">'.
$view->render().
'</div>';
->render(),
$view->render());
}
/**

View file

@ -128,12 +128,12 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
$pchar =
($changeset->getOldProperties() === $changeset->getNewProperties())
? null
: '<span title="'.pht('Properties Changed').'">M</span>';
: hsprintf('<span title="%s">M</span>', pht('Properties Changed'));
$fname = $changeset->getFilename();
$cov = $this->renderCoverage($coverage, $fname);
if ($cov === null) {
$mcov = $cov = '<em>-</em>';
$mcov = $cov = phutil_tag('em', array(), '-');
} else {
$mcov = phutil_tag(
'div',
@ -144,21 +144,21 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
(isset($this->visibleChangesets[$id]) ? 'Loading...' : '?'));
}
$rows[] =
'<tr>'.
phutil_tag(
'td',
array(
'class' => 'differential-toc-char',
'title' => $chartitle,
),
$char).
'<td class="differential-toc-prop">'.$pchar.'</td>'.
'<td class="differential-toc-ftype">'.$desc.'</td>'.
'<td class="differential-toc-file">'.$link.$lines.'</td>'.
'<td class="differential-toc-cov">'.$cov.'</td>'.
'<td class="differential-toc-mcov">'.$mcov.'</td>'.
'</tr>';
$rows[] = hsprintf(
'<tr>'.
'<td class="differential-toc-char" title="%s">%s</td>'.
'<td class="differential-toc-prop">%s</td>'.
'<td class="differential-toc-ftype">%s</td>'.
'<td class="differential-toc-file">%s%s</td>'.
'<td class="differential-toc-cov">%s</td>'.
'<td class="differential-toc-mcov">%s</td>'.
'</tr>',
$chartitle, $char,
$pchar,
$desc,
$link, $lines,
$cov,
$mcov);
if ($meta) {
$rows[] = hsprintf(
'<tr>'.
@ -200,19 +200,13 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
),
pht('Show All Context'));
$buttons =
'<tr><td colspan="7">'.
$editor_link.$reveal_link.
'</td></tr>';
$buttons = hsprintf(
'<tr><td colspan="7">%s%s</td></tr>',
$editor_link,
$reveal_link);
return
id(new PhabricatorAnchorView())
->setAnchorName('toc')
->setNavigationMarker(true)
->render().
id(new PhabricatorHeaderView())
->setHeader(pht('Table of Contents'))
->render().
return hsprintf(
'%s%s'.
'<div class="differential-toc differential-panel">'.
'<table>'.
'<tr>'.
@ -220,17 +214,23 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
'<th></th>'.
'<th></th>'.
'<th>Path</th>'.
'<th class="differential-toc-cov">'.
pht('Coverage (All)').
'</th>'.
'<th class="differential-toc-mcov">'.
pht('Coverage (Touched)').
'</th>'.
'<th class="differential-toc-cov">%s</th>'.
'<th class="differential-toc-mcov">%s</th>'.
'</tr>'.
implode("\n", $rows).
$buttons.
'%s%s'.
'</table>'.
'</div>';
'</div>',
id(new PhabricatorAnchorView())
->setAnchorName('toc')
->setNavigationMarker(true)
->render(),
id(new PhabricatorHeaderView())
->setHeader(pht('Table of Contents'))
->render(),
pht('Coverage (All)'),
pht('Coverage (Touched)'),
phutil_implode_html("\n", $rows),
$buttons);
}
private function renderCoverage(array $coverage, $file) {

View file

@ -114,29 +114,31 @@ final class DifferentialLocalCommitsView extends AphrontView {
$headers = array();
$headers[] = '<th>'.pht('Commit').'</th>';
$headers[] = phutil_tag('th', array(), pht('Commit'));
if ($has_tree) {
$headers[] = '<th>'.pht('Tree').'</th>';
$headers[] = phutil_tag('th', array(), pht('Tree'));
}
if ($has_local) {
$headers[] = '<th>'.pht('Local').'</th>';
$headers[] = phutil_tag('th', array(), pht('Local'));
}
$headers[] = '<th>'.pht('Parents').'</th>';
$headers[] = '<th>'.pht('Author').'</th>';
$headers[] = '<th>'.pht('Summary').'</th>';
$headers[] = '<th>'.pht('Date').'</th>';
$headers[] = phutil_tag('th', array(), pht('Parents'));
$headers[] = phutil_tag('th', array(), pht('Author'));
$headers[] = phutil_tag('th', array(), pht('Summary'));
$headers[] = phutil_tag('th', array(), pht('Date'));
$headers = '<tr>'.implode('', $headers).'</tr>';
$headers = phutil_tag('tr', array(), $headers);
return
id(new PhabricatorHeaderView())
->setHeader(pht('Local Commits'))
->render().
$header = id(new PhabricatorHeaderView())
->setHeader(pht('Local Commits'))
->render();
return hsprintf(
'%s'.
'<div class="differential-panel">'.
'<table class="differential-local-commits-table">'.
$headers.
implode("\n", $rows).
'</table>'.
'</div>';
'<table class="differential-local-commits-table">%s%s</table>'.
'</div>',
$header,
$headers,
phutil_implode_html("\n", $rows));
}
}

View file

@ -11,13 +11,13 @@ final class DifferentialPrimaryPaneView extends AphrontView {
public function render() {
return phutil_render_tag(
return phutil_tag(
'div',
array(
'class' => 'differential-primary-pane',
'id' => $this->id,
),
$this->renderChildren());
$this->renderHTMLChildren());
}
}

View file

@ -187,14 +187,12 @@ final class DifferentialRevisionCommentListView extends AphrontView {
$hidden = null;
}
return javelin_render_tag(
return javelin_tag(
'div',
array(
'class' => 'differential-comment-list',
'id' => $this->getID(),
),
implode("\n", $header).
$hidden.
implode("\n", $visible));
array_merge($header, array($hidden), $visible));
}
}

View file

@ -87,7 +87,11 @@ final class DifferentialRevisionDetailView extends AphrontView {
}
$properties->setHasKeyboardShortcuts(true);
return $header->render() . $actions->render() . $properties->render();
return hsprintf(
'%s%s%s',
$header->render(),
$actions->render(),
$properties->render());
}
private function renderHeader(DifferentialRevision $revision) {

View file

@ -177,9 +177,8 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
DifferentialChangesetParser::WHITESPACE_SHOW_ALL => 'Show All',
);
$select = '<select name="whitespace">';
foreach ($options as $value => $label) {
$select .= phutil_tag(
$options[$value] = phutil_tag(
'option',
array(
'value' => $value,
@ -189,34 +188,39 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
),
$label);
}
$select .= '</select>';
$select = phutil_tag('select', array('name' => 'whitespace'), $options);
return
id(new PhabricatorHeaderView())
->setHeader(pht('Revision Update History'))
->render() .
array_unshift($rows, phutil_tag('tr', array(), array(
phutil_tag('th', array(), pht('Diff')),
phutil_tag('th', array(), pht('ID')),
phutil_tag('th', array(), pht('Base')),
phutil_tag('th', array(), pht('Description')),
phutil_tag('th', array(), pht('Created')),
phutil_tag('th', array(), pht('Lint')),
phutil_tag('th', array(), pht('Unit')),
)));
return hsprintf(
'%s'.
'<div class="differential-revision-history differential-panel">'.
'<form action="#toc">'.
'<table class="differential-revision-history-table">'.
'<tr>'.
'<th>'.pht('Diff').'</th>'.
'<th>'.pht('ID').'</th>'.
'<th>'.pht('Base').'</th>'.
'<th>'.pht('Description').'</th>'.
'<th>'.pht('Created').'</th>'.
'<th>'.pht('Lint').'</th>'.
'<th>'.pht('Unit').'</th>'.
'</tr>'.
implode("\n", $rows).
'%s'.
'<tr>'.
'<td colspan="9" class="diff-differ-submit">'.
'<label>'.pht('Whitespace Changes: %s', $select).'</label>'.
'<button>'.pht('Show Diff').'</button>'.
'<label>%s</label>'.
'<button>%s</button>'.
'</td>'.
'</tr>'.
'</table>'.
'</form>'.
'</div>';
'</div>',
id(new PhabricatorHeaderView())
->setHeader(pht('Revision Update History'))
->render(),
phutil_implode_html("\n", $rows),
pht('Whitespace Changes: %s', $select),
pht('Show Diff'));
}
const STAR_NONE = 'none';

View file

@ -87,10 +87,10 @@ final class DiffusionCommentListView extends AphrontView {
++$num;
}
return
'<div class="diffusion-comment-list">'.
$this->renderSingleView($comments).
'</div>';
return phutil_tag(
'div',
array('class' => 'diffusion-comment-list'),
$comments);
}
}

View file

@ -40,8 +40,8 @@ final class PhabricatorFeedBuilder {
if ($date !== $last_date) {
if ($last_date !== null) {
$null_view->appendChild(
'<div class="phabricator-feed-story-date-separator"></div>');
$null_view->appendChild(hsprintf(
'<div class="phabricator-feed-story-date-separator"></div>'));
}
$last_date = $date;
$null_view->appendChild(
@ -59,10 +59,9 @@ final class PhabricatorFeedBuilder {
$null_view->appendChild($view);
}
return id(new AphrontNullView())->appendChild(
'<div class="phabricator-feed-frame">'.
$null_view->render().
'</div>');
return id(new AphrontNullView())->appendChild(hsprintf(
'<div class="phabricator-feed-frame">%s</div>',
$null_view->render()));
}
}

View file

@ -58,7 +58,7 @@ final class PhabricatorFeedStoryView extends PhabricatorFeedView {
$classes[] = 'phabricator-notification-unread';
}
return javelin_render_tag(
return javelin_tag(
'div',
array(
'class' => implode(' ', $classes),
@ -67,29 +67,29 @@ final class PhabricatorFeedStoryView extends PhabricatorFeedView {
'href' => $this->getHref(),
),
),
$this->title);
phutil_safe_html($this->title));
}
public function render() {
$head = phutil_render_tag(
$head = phutil_tag(
'div',
array(
'class' => 'phabricator-feed-story-head',
),
nonempty($this->title, 'Untitled Story'));
nonempty(phutil_safe_html($this->title), 'Untitled Story'));
$body = null;
$foot = null;
$image_style = null;
if (!$this->oneLine) {
$body = phutil_render_tag(
$body = phutil_tag(
'div',
array(
'class' => 'phabricator-feed-story-body',
),
$this->renderChildren());
phutil_safe_html($this->renderChildren()));
if ($this->epoch) {
$foot = phabricator_datetime($this->epoch, $this->user);
@ -111,7 +111,7 @@ final class PhabricatorFeedStoryView extends PhabricatorFeedView {
require_celerity_resource('phabricator-feed-css');
return phutil_render_tag(
return phutil_tag(
'div',
array(
'class' => $this->oneLine

View file

@ -88,36 +88,32 @@ final class ManiphestTaskDetailController extends ManiphestController {
if ($parent_task) {
$context_bar = new AphrontContextBarView();
$context_bar->addButton(
phutil_tag(
'a',
array(
'href' => '/maniphest/task/create/?parent='.$parent_task->getID(),
'class' => 'green button',
),
'Create Another Subtask'));
$context_bar->appendChild(
'Created a subtask of <strong>'.
$this->getHandle($parent_task->getPHID())->renderLink().
'</strong>');
$context_bar->addButton(phutil_tag(
'a',
array(
'href' => '/maniphest/task/create/?parent='.$parent_task->getID(),
'class' => 'green button',
),
'Create Another Subtask'));
$context_bar->appendChild(hsprintf(
'Created a subtask of <strong>%s</strong>',
$this->getHandle($parent_task->getPHID())->renderLink()));
} else if ($workflow == 'create') {
$context_bar = new AphrontContextBarView();
$context_bar->addButton('<label>Create Another:</label>');
$context_bar->addButton(
phutil_tag(
'a',
array(
'href' => '/maniphest/task/create/?template='.$task->getID(),
'class' => 'green button',
),
$context_bar->addButton(phutil_tag('label', array(), 'Create Another'));
$context_bar->addButton(phutil_tag(
'a',
array(
'href' => '/maniphest/task/create/?template='.$task->getID(),
'class' => 'green button',
),
'Similar Task'));
$context_bar->addButton(
phutil_tag(
'a',
array(
'href' => '/maniphest/task/create/',
'class' => 'green button',
),
$context_bar->addButton(phutil_tag(
'a',
array(
'href' => '/maniphest/task/create/',
'class' => 'green button',
),
'Empty Task'));
$context_bar->appendChild('New task created.');
}

View file

@ -298,13 +298,14 @@ final class ManiphestTaskListController extends ManiphestController {
require_celerity_resource('maniphest-task-summary-css');
$list_container = new AphrontNullView();
$list_container->appendChild('<div class="maniphest-list-container">');
$list_container->appendChild(hsprintf(
'<div class="maniphest-list-container">'));
if (!$have_tasks) {
$list_container->appendChild(
$list_container->appendChild(hsprintf(
'<h1 class="maniphest-task-group-header">'.
'No matching tasks.'.
'</h1>');
'</h1>'));
} else {
$pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'offset');
@ -316,14 +317,13 @@ final class ManiphestTaskListController extends ManiphestController {
$max = min($pager->getOffset() + $page_size, $total_count);
$tot = $total_count;
$cur = number_format($cur);
$max = number_format($max);
$tot = number_format($tot);
$list_container->appendChild(
$list_container->appendChild(hsprintf(
'<div class="maniphest-total-result-count">'.
"Displaying tasks {$cur} - {$max} of {$tot}.".
'</div>');
"Displaying tasks %s - %s of %s.".
'</div>',
number_format($cur),
number_format($max),
number_format($tot)));
$selector = new AphrontNullView();
@ -334,7 +334,7 @@ final class ManiphestTaskListController extends ManiphestController {
($group == 'none' || $group == 'priority');
$lists = new AphrontNullView();
$lists->appendChild('<div class="maniphest-group-container">');
$lists->appendChild(hsprintf('<div class="maniphest-group-container">'));
foreach ($tasks as $group => $list) {
$task_list = new ManiphestTaskListView();
$task_list->setShowBatchControls(true);
@ -367,14 +367,14 @@ final class ManiphestTaskListController extends ManiphestController {
$lists->appendChild($panel);
}
$lists->appendChild('</div>');
$lists->appendChild(hsprintf('</div>'));
$selector->appendChild($lists);
$selector->appendChild($this->renderBatchEditor($query));
$form_id = celerity_generate_unique_node_id();
$selector = phabricator_render_form(
$selector = phabricator_form(
$user,
array(
'method' => 'POST',
@ -394,7 +394,7 @@ final class ManiphestTaskListController extends ManiphestController {
));
}
$list_container->appendChild('</div>');
$list_container->appendChild(hsprintf('</div>'));
$nav->appendChild($list_container);
$title = pht('Task List');
@ -678,25 +678,21 @@ final class ManiphestTaskListController extends ManiphestController {
),
'Export Tasks to Excel...');
return
return hsprintf(
'<div class="maniphest-batch-editor">'.
'<div class="batch-editor-header">Batch Task Editor</div>'.
'<table class="maniphest-batch-editor-layout">'.
'<tr>'.
'<td>'.
$select_all.
$select_none.
'</td>'.
'<td>'.
$export.
'</td>'.
'<td id="batch-select-status-cell">'.
'0 Selected Tasks'.
'</td>'.
'<td class="batch-select-submit-cell">'.$submit.'</td>'.
'<td>%s%s</td>'.
'<td>%s</td>'.
'<td id="batch-select-status-cell">0 Selected Tasks</td>'.
'<td class="batch-select-submit-cell">%s</td>'.
'</tr>'.
'</table>'.
'</table>';
'</table>',
$select_all, $select_none,
$export,
$submit);
}
private function buildQueryFromRequest() {

View file

@ -179,7 +179,7 @@ final class ManiphestTransactionDetailView extends ManiphestView {
}
if ($this->getRenderSummaryOnly()) {
return implode("\n", $descs);
return phutil_implode_html("\n", $descs);
}
if ($comment_transaction && $comment_transaction->hasComments()) {

View file

@ -102,10 +102,10 @@ final class ManiphestTransactionListView extends ManiphestView {
$views[] = $view->render();
}
return
'<div class="maniphest-transaction-list-view">'.
implode("\n", $views).
'</div>';
return phutil_tag(
'div',
array('class' => 'maniphest-transaction-list-view'),
$views);
}
}

View file

@ -157,7 +157,7 @@ final class PhrictionDocumentController
$version_note = $version_note->render();
}
$children = $this->renderChildren($slug);
$children = $this->renderDocumentChildren($slug);
$crumbs = $this->buildApplicationCrumbs();
$crumb_views = $this->renderBreadcrumbs($slug);
@ -225,7 +225,7 @@ final class PhrictionDocumentController
->setHref(PhrictionDocument::getSlugURI($slug, 'history')));
}
private function renderChildren($slug) {
private function renderDocumentChildren($slug) {
$document_dao = new PhrictionDocument();
$content_dao = new PhrictionContent();
$conn = $document_dao->establishConnection('r');

View file

@ -44,14 +44,14 @@ final class PonderAddAnswerView extends AphrontView {
id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Make it so'));
$preview =
$preview = hsprintf(
'<div class="aphront-panel-flush">'.
'<div id="answer-preview">'.
'<span class="aphront-panel-preview-loading-text">'.
'Loading answer preview...'.
'</span>'.
'</div>'.
'</div>';
'</div>');
Javelin::initBehavior(
'ponder-feedback-preview',

View file

@ -43,34 +43,29 @@ final class PonderQuestionSummaryView extends AphrontView {
'</div>',
$question->getAnswerCount());
$title =
'<h2 class="ponder-question-title">'.
phutil_tag(
'a',
array(
"href" => '/Q' . $question->getID(),
),
'Q' . $question->getID() .
' ' . $question->getTitle()
) .
'</h2>';
$title = hsprintf('<h2 class="ponder-question-title">%s</h2>',
phutil_tag(
'a',
array(
"href" => '/Q' . $question->getID(),
),
'Q' . $question->getID() .
' ' . $question->getTitle()
));
$rhs =
$rhs = hsprintf(
'<div class="ponder-metadata">'.
$title.
'<span class="ponder-small-metadata">'.
'asked on '.
phabricator_datetime($question->getDateCreated(), $user).
' by ' . $authorlink.
'</span>'.
'</div>';
'%s <span class="ponder-small-metadata">asked on %s by %s</span>'.
'</div>',
$title,
phabricator_datetime($question->getDateCreated(), $user),
$authorlink);
$summary =
'<div class="ponder-question-summary">'.
$votecount.
$answercount.
$rhs.
'</div>';
$summary = hsprintf(
'<div class="ponder-question-summary">%s%s%s</div>',
$votecount,
$answercount,
$rhs);
return $summary;

View file

@ -63,7 +63,7 @@ final class PonderVotableView extends AphrontView {
),
$this->count);
return javelin_render_tag(
return javelin_tag(
'div',
array(
'class' => 'ponder-votable',
@ -80,12 +80,12 @@ final class PonderVotableView extends AphrontView {
'class' => 'ponder-votebox',
),
array($up, $count, $down)),
phutil_render_tag(
phutil_tag(
'div',
array(
'class' => 'ponder-votebox-content',
),
$this->renderChildren()),
$this->renderHTMLChildren()),
));
}

View file

@ -70,21 +70,25 @@ final class PhabricatorSearchResultView extends AphrontView {
break;
}
return
return hsprintf(
'<div class="phabricator-search-result">'.
$img.
'%s'.
'<div class="result-desc">'.
phutil_tag(
'a',
array(
'class' => 'result-name',
'href' => $handle->getURI(),
),
$this->emboldenQuery($object_name)).
'<div class="result-type">'.$type_name.' &middot; '.$link.'</div>'.
'%s'.
'<div class="result-type">%s &middot; %s</div>'.
'</div>'.
'<div style="clear: both;"></div>'.
'</div>';
'</div>',
$img,
phutil_tag(
'a',
array(
'class' => 'result-name',
'href' => $handle->getURI(),
),
$this->emboldenQuery($object_name)),
$type_name,
$link);
}
private function emboldenQuery($str) {

View file

@ -8,7 +8,7 @@ final class JavelinViewExampleServerView extends AphrontView {
array(
'class' => 'server-view',
),
$this->renderChildren());
$this->renderHTMLChildren());
}
}

View file

@ -15,7 +15,7 @@ final class PhabricatorInlineSummaryView extends AphrontView {
public function render() {
require_celerity_resource('inline-comment-summary-css');
return $this->renderHeader().$this->renderTable();
return hsprintf('%s%s', $this->renderHeader(), $this->renderTable());
}
private function renderHeader() {

View file

@ -3,7 +3,7 @@
final class AphrontNullView extends AphrontView {
public function render() {
return $this->renderChildren();
return $this->renderHTMLChildren();
}
}

View file

@ -52,7 +52,7 @@ abstract class AphrontView extends Phobject {
foreach ($child as $element) {
$out[] = $this->renderSingleView($element);
}
return implode('', $out);
return phutil_implode_html('', $out);
} else {
return $child;
}
@ -60,7 +60,7 @@ abstract class AphrontView extends Phobject {
final protected function renderHTMLView($child) {
if ($child instanceof AphrontView) {
return phutil_safe_html($child->render());
return $child->render();
} else if ($child instanceof PhutilSafeHTML) {
return $child;
} else if (is_array($child)) {
@ -68,9 +68,9 @@ abstract class AphrontView extends Phobject {
foreach ($child as $element) {
$out[] = $this->renderHTMLView($element);
}
return phutil_safe_html(implode('', $out));
return phutil_implode_html('', $out);
} else {
return phutil_safe_html(phutil_escape_html($child));
return hsprintf('%s', $child);
}
}

View file

@ -44,14 +44,18 @@ final class AphrontAttachedFileView extends AphrontView {
),
"\xE2\x9C\x96"); // "Heavy Multiplication X"
return
return hsprintf(
'<table class="aphront-attached-file-view">
<tr>
<td>'.$thumb.'</td>
<th><strong>'.$name.'</strong><br />'.$size.'</th>
<td class="aphront-attached-file-view-remove">'.$remove.'</td>
<td>%s</td>
<th><strong>%s</strong><br />%s</th>
<td class="aphront-attached-file-view-remove">%s</td>
</tr>
</table>';
</table>',
$thumb,
$name,
$size,
$remove);
}
}

View file

@ -120,10 +120,10 @@ final class AphrontCursorPagerView extends AphrontView {
"Next \xE2\x80\xBA");
}
return
'<div class="aphront-pager-view">'.
implode('', $links).
'</div>';
return phutil_tag(
'div',
array('class' => 'aphront-pager-view'),
$links);
}
}

View file

@ -115,7 +115,7 @@ final class AphrontPagerView extends AphrontView {
if ($max - $min > $last) {
$max = $min + $last;
if ($max == $min) {
return '<div class="aphront-pager-view"></div>';
return phutil_tag('div', array('class' => 'aphront-pager-view'), '');
}
}
@ -196,10 +196,10 @@ final class AphrontPagerView extends AphrontView {
$label);
}
return
'<div class="aphront-pager-view">'.
implode('', $rendered_links).
'</div>';
return phutil_tag(
'div',
array('class' => 'aphront-pager-view'),
$rendered_links);
}
private function getDisplayIndex($page_index) {

View file

@ -15,18 +15,16 @@ final class AphrontContextBarView extends AphrontView {
require_celerity_resource('aphront-contextbar-view-css');
return
return hsprintf(
'<div class="aphront-contextbar-view">'.
'<div class="aphront-contextbar-core">'.
'<div class="aphront-contextbar-buttons">'.
$view->render().
'</div>'.
'<div class="aphront-contextbar-content">'.
$this->renderChildren().
'</div>'.
'<div class="aphront-contextbar-buttons">%s</div>'.
'<div class="aphront-contextbar-content">%s</div>'.
'</div>'.
'<div style="clear: both;"></div>'.
'</div>';
'</div>',
$view->render(),
$this->renderHTMLChildren());
}
}

View file

@ -17,18 +17,15 @@ final class AphrontCrumbsView extends AphrontView {
foreach ($this->crumbs as $crumb) {
$out[] = $this->renderSingleView($crumb);
}
$out = implode(
'<span class="aphront-crumbs-spacer">'.
"\xC2\xBB".
'</span>',
$out = phutil_implode_html(
hsprintf('<span class="aphront-crumbs-spacer">'."\xC2\xBB".'</span>'),
$out);
return
return hsprintf(
'<div class="aphront-crumbs-view">'.
'<div class="aphront-crumbs-content">'.
$out.
'</div>'.
'</div>';
'<div class="aphront-crumbs-content">%s</div>'.
'</div>',
$out);
}
}

View file

@ -4,14 +4,13 @@ final class AphrontListFilterView extends AphrontView {
public function render() {
require_celerity_resource('aphront-list-filter-view-css');
return
return hsprintf(
'<table class="aphront-list-filter-view">'.
'<tr>'.
'<td class="aphront-list-filter-view-controls">'.
$this->renderChildren().
'</td>'.
'<td class="aphront-list-filter-view-controls">%s</td>'.
'</tr>'.
'</table>';
'</table>',
$this->renderHTMLChildren());
}
}

View file

@ -3,10 +3,9 @@
final class AphrontMiniPanelView extends AphrontView {
public function render() {
return
'<div class="aphront-mini-panel-view">'.
$this->renderChildren().
'</div>';
return hsprintf(
'<div class="aphront-mini-panel-view">%s</div>',
$this->renderHTMLChildren());
}
}

View file

@ -98,13 +98,14 @@ final class AphrontPanelView extends AphrontView {
$classes[] = 'aphront-panel-width-'.$this->width;
}
return phutil_render_tag(
return phutil_tag(
'div',
array(
'class' => implode(' ', $classes),
'id' => $this->id,
),
$header_elements.$table);
// TODO: [HTML] Make HTML safe.
phutil_safe_html($header_elements.$table));
}
}

View file

@ -277,21 +277,26 @@ final class AphrontSideNavFilterView extends AphrontView {
$nav_classes = array_merge($nav_classes, $this->classes);
return phutil_render_tag(
return phutil_tag(
'div',
array(
'class' => implode(' ', $nav_classes),
'id' => $main_id,
),
$local_menu.
$flex_bar.
phutil_render_tag(
'div',
array(
'class' => 'phabricator-nav-content',
'id' => $content_id,
),
$crumbs.$this->renderChildren()));
array(
$local_menu,
$flex_bar,
phutil_tag(
'div',
array(
'class' => 'phabricator-nav-content',
'id' => $content_id,
),
array(
$crumbs,
phutil_safe_html($this->renderChildren()),
))
));
}
}

View file

@ -31,7 +31,7 @@ final class PhabricatorFileLinkListView extends AphrontView {
$file_links[] = $view->render();
}
return implode('<br />', $file_links);
return phutil_implode_html(phutil_tag('br'), $file_links);
}
}

View file

@ -67,9 +67,9 @@ final class PhabricatorProfileHeaderView extends AphrontView {
</tr>
</table>',
$this->profileName,
phutil_safe_html(self::renderSingleView($this->profileActions)),
self::renderSingleView($this->profileActions),
$image,
$description).
$this->renderChildren();
$this->renderHTMLChildren();
}
}

View file

@ -62,20 +62,22 @@ final class PhabricatorTransactionView extends AphrontView {
$transaction_id = $this->anchorName ? 'anchor-'.$this->anchorName : null;
return phutil_render_tag(
return phutil_tag(
'div',
array(
'class' => 'phabricator-transaction-view',
'id' => $transaction_id,
'style' => $style,
),
'<div class="phabricator-transaction-detail '.$classes.'">'.
'<div class="phabricator-transaction-header">'.
$info.
$actions.
'</div>'.
$content.
'</div>');
// TODO: [HTML] Make HTML safe.
phutil_safe_html(
'<div class="phabricator-transaction-detail '.$classes.'">'.
'<div class="phabricator-transaction-header">'.
$info.
$actions.
'</div>'.
$content.
'</div>'));
}

View file

@ -73,7 +73,9 @@ abstract class AphrontPageView extends AphrontView {
EOHTML;
$response = $this->willSendResponse($response);
return $response;
// TODO: [HTML] Make HTML safe.
return phutil_safe_html($response);
}

View file

@ -13,15 +13,15 @@ final class AphrontRequestFailureView extends AphrontView {
final public function render() {
require_celerity_resource('aphront-request-failure-view-css');
return
return hsprintf(
'<div class="aphront-request-failure-view">'.
'<div class="aphront-request-failure-head">'.
phutil_tag('h1', array(), $this->header).
'<h1>%s</h1>'.
'</div>'.
'<div class="aphront-request-failure-body">'.
$this->renderChildren().
'</div>'.
'</div>';
'<div class="aphront-request-failure-body">%s</div>'.
'</div>',
$this->header,
$this->renderHTMLChildren());
}
}

View file

@ -60,18 +60,19 @@ final class PhabricatorMainMenuSearchView extends AphrontView {
'value' => $scope,
));
$form = phabricator_render_form(
$form = phabricator_form(
$user,
array(
'action' => '/search/',
'method' => 'POST',
),
'<div class="phabricator-main-menu-search-container">'.
$input.
'<button>Search</button>'.
$scope_input.
$target.
'</div>');
hsprintf(
'<div class="phabricator-main-menu-search-container">'.
'%s<button>Search</button>%s%s'.
'</div>',
$input,
$scope_input,
$target));
return $form;
}

View file

@ -51,7 +51,7 @@ final class PhabricatorMainMenuView extends AphrontView {
$phabricator_menu = $this->renderPhabricatorMenu();
if ($alerts) {
$alerts = phutil_render_tag(
$alerts = phutil_tag(
'div',
array(
'class' => 'phabricator-main-menu-alerts',
@ -65,14 +65,14 @@ final class PhabricatorMainMenuView extends AphrontView {
$application_menu->addClass('phabricator-application-menu');
}
return phutil_render_tag(
return phutil_tag(
'div',
array(
'class' => 'phabricator-main-menu',
'id' => $header_id,
),
self::renderSingleView(
array(
array(
self::renderSingleView(array(
$this->renderPhabricatorMenuButton($header_id),
$application_menu
? $this->renderApplicationMenuButton($header_id)
@ -81,8 +81,9 @@ final class PhabricatorMainMenuView extends AphrontView {
$alerts,
$phabricator_menu,
$application_menu,
))).
self::renderSingleView($menus);
)),
self::renderSingleView($menus),
));
}
private function renderSearch() {