1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-04-10 19:38:34 +02:00

Convert AphrontTableView to safe HTML

Summary:
Lots of killed `phutil_escape_html()`.

Done by searching for `AphrontTableView` and then `$rows` (usually) backwards.

Test Plan:
Looked at homepage.

  echo id(new AphrontTableView(array(array('<'))))->render();

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4884
This commit is contained in:
vrana 2013-02-09 12:10:16 -08:00
parent 58b6e2cac6
commit 9b8da73765
53 changed files with 206 additions and 262 deletions

View file

@ -349,7 +349,7 @@ class AphrontDefaultApplicationConfiguration
), ),
$relative); $relative);
} }
$file_name = $file_name.' : '.(int)$part['line']; $file_name = hsprintf('%s : %d', $file_name, $part['line']);
} else { } else {
$file_name = phutil_tag('em', array(), '(Internal)'); $file_name = phutil_tag('em', array(), '(Internal)');
} }
@ -357,9 +357,9 @@ class AphrontDefaultApplicationConfiguration
$rows[] = array( $rows[] = array(
$depth--, $depth--,
phutil_escape_html($lib), $lib,
$file_name, $file_name,
phutil_escape_html($where), $where,
); );
} }
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);
@ -383,7 +383,7 @@ class AphrontDefaultApplicationConfiguration
'<div class="exception-trace-header">Stack Trace</div>'. '<div class="exception-trace-header">Stack Trace</div>'.
'%s', '%s',
'</div>', '</div>',
phutil_safe_html($table->render())); $table->render());
} }
} }

View file

@ -49,10 +49,7 @@ final class DarkConsoleEventPlugin extends DarkConsolePlugin {
$rows = array(); $rows = array();
foreach ($data['listeners'] as $listener) { foreach ($data['listeners'] as $listener) {
$rows[] = array( $rows[] = array($listener['id'], $listener['class']);
phutil_escape_html($listener['id']),
phutil_escape_html($listener['class']),
);
} }
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);
@ -77,7 +74,7 @@ final class DarkConsoleEventPlugin extends DarkConsolePlugin {
$rows = array(); $rows = array();
foreach ($data['events'] as $event) { foreach ($data['events'] as $event) {
$rows[] = array( $rows[] = array(
phutil_escape_html($event['type']), $event['type'],
$event['stopped'] ? 'STOPPED' : null, $event['stopped'] ? 'STOPPED' : null,
); );
} }

View file

@ -43,8 +43,8 @@ final class DarkConsoleRequestPlugin extends DarkConsolePlugin {
$rows = array(); $rows = array();
foreach ($map as $key => $value) { foreach ($map as $key => $value) {
$rows[] = array( $rows[] = array(
phutil_escape_html($key), $key,
phutil_escape_html(is_array($value) ? json_encode($value) : $value), (is_array($value) ? json_encode($value) : $value),
); );
} }

View file

@ -224,23 +224,18 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
$row['explain']['reason']); $row['explain']['reason']);
} }
$info = phutil_escape_html($info);
break; break;
case 'connect': case 'connect':
$info = $row['host'].':'.$row['database']; $info = $row['host'].':'.$row['database'];
$info = phutil_escape_html($info);
break; break;
case 'exec': case 'exec':
$info = $row['command']; $info = $row['command'];
$info = phutil_escape_html($info);
break; break;
case 'conduit': case 'conduit':
$info = $row['method']; $info = $row['method'];
$info = phutil_escape_html($info);
break; break;
case 'http': case 'http':
$info = $row['uri']; $info = $row['uri'];
$info = phutil_escape_html($info);
break; break;
default: default:
$info = '-'; $info = '-';
@ -248,7 +243,7 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
} }
$rows[] = array( $rows[] = array(
phutil_escape_html($row['type']), $row['type'],
'+'.number_format(1000 * ($row['begin'] - $data['start'])).' ms', '+'.number_format(1000 * ($row['begin'] - $data['start'])).' ms',
number_format(1000000 * $row['duration']).' us', number_format(1000000 * $row['duration']).' us',
$info, $info,

View file

@ -70,10 +70,10 @@ final class PhabricatorAuditCommitListView extends AphrontView {
$rows[] = array( $rows[] = array(
$commit_name, $commit_name,
$author_name, $author_name,
phutil_escape_html($commit->getCommitData()->getSummary()), $commit->getCommitData()->getSummary(),
PhabricatorAuditCommitStatusConstants::getStatusName( PhabricatorAuditCommitStatusConstants::getStatusName(
$commit->getAuditStatus()), $commit->getAuditStatus()),
implode(', ', $auditors), array_interleave(', ', $auditors),
phabricator_datetime($commit->getEpoch(), $this->user), phabricator_datetime($commit->getEpoch(), $this->user),
); );
} }

View file

@ -129,10 +129,7 @@ final class PhabricatorAuditListView extends AphrontView {
} }
$reasons = $audit->getAuditReasons(); $reasons = $audit->getAuditReasons();
foreach ($reasons as $key => $reason) { $reasons = array_interleave(phutil_tag('br'), $reasons);
$reasons[$key] = phutil_escape_html($reason);
}
$reasons = implode('<br />', $reasons);
$status_code = $audit->getAuditStatus(); $status_code = $audit->getAuditStatus();
$status = PhabricatorAuditStatusConstants::getStatusName($status_code); $status = PhabricatorAuditStatusConstants::getStatusName($status_code);
@ -140,10 +137,10 @@ final class PhabricatorAuditListView extends AphrontView {
$auditor_handle = $this->getHandle($audit->getAuditorPHID()); $auditor_handle = $this->getHandle($audit->getAuditorPHID());
$rows[] = array( $rows[] = array(
$commit_name, $commit_name,
phutil_escape_html($commit_desc), $commit_desc,
$committed, $committed,
$auditor_handle->renderLink(), $auditor_handle->renderLink(),
phutil_escape_html($status), $status,
$reasons, $reasons,
); );

View file

@ -21,11 +21,11 @@ final class PhabricatorOAuthDiagnosticsController
$client_id = $provider->getClientID(); $client_id = $provider->getClientID();
$client_secret = $provider->getClientSecret(); $client_secret = $provider->getClientSecret();
$key = $provider->getProviderKey(); $key = $provider->getProviderKey();
$name = phutil_escape_html($provider->getProviderName()); $name = $provider->getProviderName();
$res_ok = '<strong style="color: #00aa00;">OK</strong>'; $res_ok = hsprintf('<strong style="color: #00aa00;">OK</strong>');
$res_no = '<strong style="color: #aa0000;">NO</strong>'; $res_no = hsprintf('<strong style="color: #aa0000;">NO</strong>');
$res_na = '<strong style="color: #999999;">N/A</strong>'; $res_na = hsprintf('<strong style="color: #999999;">N/A</strong>');
$results = array(); $results = array();
$auth_key = $key . '.auth-enabled'; $auth_key = $key . '.auth-enabled';
@ -159,10 +159,10 @@ final class PhabricatorOAuthDiagnosticsController
$rows = array(); $rows = array();
foreach ($results as $key => $result) { foreach ($results as $key => $result) {
$rows[] = array( $rows[] = array(
phutil_escape_html($key), $key,
$result[0], $result[0],
phutil_escape_html($result[1]), $result[1],
phutil_escape_html($result[2]), $result[2],
); );
} }

View file

@ -346,7 +346,7 @@ final class PhabricatorConduitAPIController
if ($request) { if ($request) {
foreach ($request->getAllParameters() as $key => $value) { foreach ($request->getAllParameters() as $key => $value) {
$param_rows[] = array( $param_rows[] = array(
phutil_escape_html($key), $key,
$this->renderAPIValue($value), $this->renderAPIValue($value),
); );
} }
@ -362,7 +362,7 @@ final class PhabricatorConduitAPIController
$result_rows = array(); $result_rows = array();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
$result_rows[] = array( $result_rows[] = array(
phutil_escape_html($key), $key,
$this->renderAPIValue($value), $this->renderAPIValue($value),
); );
} }

View file

@ -65,9 +65,9 @@ final class PhabricatorConduitLogController
} }
$rows[] = array( $rows[] = array(
$call->getConnectionID(), $call->getConnectionID(),
phutil_escape_html($conn->getUserName()), $conn->getUserName(),
phutil_escape_html($call->getMethod()), $call->getMethod(),
phutil_escape_html($call->getError()), $call->getError(),
number_format($call->getDuration()).' us', number_format($call->getDuration()).' us',
phabricator_datetime($call->getDateCreated(), $user), phabricator_datetime($call->getDateCreated(), $user),
); );

View file

@ -14,13 +14,12 @@ final class PhabricatorConfigAllController
$key = $option->getKey(); $key = $option->getKey();
if ($option->getMasked()) { if ($option->getMasked()) {
$value = '<em>'.pht('Masked').'</em>'; $value = phutil_tag('em', array(), pht('Masked'));
} else if ($option->getHidden()) { } else if ($option->getHidden()) {
$value = '<em>'.pht('Hidden').'</em>'; $value = phutil_tag('em', array(), pht('Hidden'));
} else { } else {
$value = PhabricatorEnv::getEnvConfig($key); $value = PhabricatorEnv::getEnvConfig($key);
$value = PhabricatorConfigJSON::prettyPrintJSON($value); $value = PhabricatorConfigJSON::prettyPrintJSON($value);
$value = phutil_escape_html($value);
} }
$rows[] = array( $rows[] = array(

View file

@ -283,7 +283,7 @@ final class ConpherenceViewController extends
'src' => $thumb 'src' => $thumb
), ),
''), ''),
phutil_escape_html($file->getName()), $file->getName(),
); );
} }
$header = id(new PhabricatorHeaderView()) $header = id(new PhabricatorHeaderView())

View file

@ -46,7 +46,7 @@ final class PhabricatorCountdownListController
'Delete'); 'Delete');
} }
$rows[] = array( $rows[] = array(
phutil_escape_html($timer->getID()), $timer->getID(),
$handles[$timer->getAuthorPHID()]->renderLink(), $handles[$timer->getAuthorPHID()]->renderLink(),
phutil_tag( phutil_tag(
'a', 'a',

View file

@ -30,7 +30,7 @@ final class PhabricatorDaemonConsoleController
$rows = array(); $rows = array();
foreach ($completed_info as $class => $info) { foreach ($completed_info as $class => $info) {
$rows[] = array( $rows[] = array(
phutil_escape_html($class), $class,
number_format($info['n']), number_format($info['n']),
number_format((int)($info['duration'] / $info['n'])).' us', number_format((int)($info['duration'] / $info['n'])).' us',
); );
@ -127,7 +127,7 @@ final class PhabricatorDaemonConsoleController
$rows = array(); $rows = array();
foreach ($queued as $row) { foreach ($queued as $row) {
$rows[] = array( $rows[] = array(
phutil_escape_html($row['taskClass']), $row['taskClass'],
number_format($row['N']), number_format($row['N']),
); );
} }

View file

@ -60,7 +60,7 @@ final class PhabricatorDaemonLogEventsView extends AphrontView {
} }
$row = array( $row = array(
phutil_escape_html($event->getLogType()), $event->getLogType(),
phabricator_date($event->getEpoch(), $this->user), phabricator_date($event->getEpoch(), $this->user),
phabricator_time($event->getEpoch(), $this->user), phabricator_time($event->getEpoch(), $this->user),
phutil_escape_html_newlines($message.$more), phutil_escape_html_newlines($message.$more),

View file

@ -76,8 +76,8 @@ final class PhabricatorDaemonLogListView extends AphrontView {
$rows[] = array( $rows[] = array(
$running, $running,
phutil_escape_html($log->getDaemon()), $log->getDaemon(),
phutil_escape_html($log->getHost()), $log->getHost(),
$log->getPID(), $log->getPID(),
phabricator_date($epoch, $this->user), phabricator_date($epoch, $this->user),
phabricator_time($epoch, $this->user), phabricator_time($epoch, $this->user),

View file

@ -146,7 +146,7 @@ final class DifferentialReviewersFieldSpecification
$names[] = phutil_escape_html( $names[] = phutil_escape_html(
$this->getHandle($reviewer)->getLinkName()); $this->getHandle($reviewer)->getLinkName());
} }
$suffix = ' '.javelin_tag( $suffix = javelin_tag(
'abbr', 'abbr',
array( array(
'sigil' => 'has-tooltip', 'sigil' => 'has-tooltip',
@ -159,9 +159,12 @@ final class DifferentialReviewersFieldSpecification
} else { } else {
$suffix = null; $suffix = null;
} }
return $this->getHandle($primary_reviewer)->renderLink().$suffix; return hsprintf(
'%s %s',
$this->getHandle($primary_reviewer)->renderLink(),
$suffix);
} else { } else {
return '<em>None</em>'; return phutil_tag('em', array(), 'None');
} }
} }

View file

@ -128,18 +128,18 @@ final class DifferentialRevisionListView extends AphrontView {
} else if (array_key_exists($revision->getID(), $this->drafts)) { } else if (array_key_exists($revision->getID(), $this->drafts)) {
$src = '/rsrc/image/icon/fatcow/page_white_edit.png'; $src = '/rsrc/image/icon/fatcow/page_white_edit.png';
$flag = $flag = hsprintf(
'<a href="/D'.$revision->getID().'#comment-preview">'. '<a href="%s">%s</a>',
phutil_tag( '/D'.$revision->getID().'#comment-preview',
'img', phutil_tag(
array( 'img',
'src' => celerity_get_resource_uri($src), array(
'width' => 16, 'src' => celerity_get_resource_uri($src),
'height' => 16, 'width' => 16,
'alt' => 'Draft', 'height' => 16,
'title' => pht('Draft Comment'), 'alt' => 'Draft',
)). 'title' => pht('Draft Comment'),
'</a>'; )));
} }
$row = array($flag); $row = array($flag);

View file

@ -103,7 +103,7 @@ final class DiffusionExternalController extends DiffusionController {
'href' => $href, 'href' => $href,
), ),
'r'.$repo->getCallsign().$commit->getCommitIdentifier()), 'r'.$repo->getCallsign().$commit->getCommitIdentifier()),
phutil_escape_html($commit->loadCommitData()->getSummary()), $commit->loadCommitData()->getSummary(),
); );
} }

View file

@ -19,7 +19,7 @@ final class DiffusionHomeController extends DiffusionController {
'href' => $shortcut->getHref(), 'href' => $shortcut->getHref(),
), ),
$shortcut->getName()), $shortcut->getName()),
phutil_escape_html($shortcut->getDescription()), $shortcut->getDescription(),
); );
} }
@ -130,7 +130,7 @@ final class DiffusionHomeController extends DiffusionController {
'href' => '/diffusion/'.$repository->getCallsign().'/', 'href' => '/diffusion/'.$repository->getCallsign().'/',
), ),
$repository->getName()), $repository->getName()),
phutil_escape_html($repository->getDetail('description')), $repository->getDetail('description'),
PhabricatorRepositoryType::getNameForRepositoryType( PhabricatorRepositoryType::getNameForRepositoryType(
$repository->getVersionControlSystem()), $repository->getVersionControlSystem()),
$size, $size,

View file

@ -71,11 +71,10 @@ final class DiffusionLintController extends DiffusionController {
'<a href="%s">%s</a>', '<a href="%s">%s</a>',
$drequest->generateURI(array('action' => 'lint')), $drequest->generateURI(array('action' => 'lint')),
$drequest->getCallsign()), $drequest->getCallsign()),
phutil_escape_html(ArcanistLintSeverity::getStringForSeverity( ArcanistLintSeverity::getStringForSeverity($code['maxSeverity']),
$code['maxSeverity'])), $code['code'],
phutil_escape_html($code['code']), $code['maxName'],
phutil_escape_html($code['maxName']), $code['maxDescription'],
phutil_escape_html($code['maxDescription']),
); );
} }

View file

@ -34,10 +34,9 @@ final class DiffusionLintDetailsController extends DiffusionController {
$rows[] = array( $rows[] = array(
$path, $path,
$line, $line,
phutil_escape_html(ArcanistLintSeverity::getStringForSeverity( ArcanistLintSeverity::getStringForSeverity($message['severity']),
$message['severity'])), $message['name'],
phutil_escape_html($message['name']), $message['description'],
phutil_escape_html($message['description']),
); );
} }

View file

@ -125,9 +125,7 @@ final class DiffusionRepositoryController extends DiffusionController {
$rows = array(); $rows = array();
foreach ($properties as $key => $value) { foreach ($properties as $key => $value) {
$rows[] = array( $rows[] = array($key, $value);
phutil_escape_html($key),
phutil_escape_html($value));
} }
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);

View file

@ -81,8 +81,8 @@ final class DiffusionSymbolController extends DiffusionController {
$project_name = '-'; $project_name = '-';
} }
$file = phutil_escape_html($symbol->getPath()); $file = $symbol->getPath();
$line = phutil_escape_html($symbol->getLineNumber()); $line = $symbol->getLineNumber();
$repo = $symbol->getRepository(); $repo = $symbol->getRepository();
if ($repo) { if ($repo) {
@ -101,17 +101,17 @@ final class DiffusionSymbolController extends DiffusionController {
), ),
$file.':'.$line); $file.':'.$line);
} else if ($file) { } else if ($file) {
$location = phutil_escape_html($file.':'.$line); $location = $file.':'.$line;
} else { } else {
$location = '?'; $location = '?';
} }
$rows[] = array( $rows[] = array(
phutil_escape_html($symbol->getSymbolType()), $symbol->getSymbolType(),
phutil_escape_html($symbol->getSymbolContext()), $symbol->getSymbolContext(),
phutil_escape_html($symbol->getSymbolName()), $symbol->getSymbolName(),
phutil_escape_html($symbol->getSymbolLanguage()), $symbol->getSymbolLanguage(),
phutil_escape_html($project_name), $project_name,
$location, $location,
); );
} }

View file

@ -55,7 +55,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
$committer = self::renderName($committer); $committer = self::renderName($committer);
} }
if ($author != $committer) { if ($author != $committer) {
$author .= '/'.$committer; $author = hsprintf('%s/%s', $author, $committer);
} }
} }
@ -132,24 +132,17 @@ final class DiffusionBrowseTableView extends DiffusionView {
$browse_text = $path->getPath().'/'; $browse_text = $path->getPath().'/';
$dir_slash = '/'; $dir_slash = '/';
$browse_link = '<strong>'.$this->linkBrowse( $browse_link = phutil_tag('strong', array(), $this->linkBrowse(
$base_path.$path->getPath().$dir_slash, $base_path.$path->getPath().$dir_slash,
array( array(
'text' => $this->renderPathIcon( 'text' => $this->renderPathIcon('dir', $browse_text),
'dir', )));
$browse_text),
)).'</strong>';
} else if ($file_type == DifferentialChangeType::FILE_SUBMODULE) { } else if ($file_type == DifferentialChangeType::FILE_SUBMODULE) {
$browse_text = $path->getPath().'/'; $browse_text = $path->getPath().'/';
$browse_link = $browse_link = phutil_tag('strong', array(), $this->linkExternal(
'<strong>'. $path->getHash(),
$this->linkExternal( $path->getExternalURI(),
$path->getHash(), $this->renderPathIcon('ext', $browse_text)));
$path->getExternalURI(),
$this->renderPathIcon(
'ext',
$browse_text)).
'</strong>';
} else { } else {
if ($file_type == DifferentialChangeType::FILE_SYMLINK) { if ($file_type == DifferentialChangeType::FILE_SYMLINK) {
$type = 'link'; $type = 'link';
@ -190,7 +183,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
$need_pull[$uri] = $dict; $need_pull[$uri] = $dict;
foreach ($dict as $k => $uniq) { foreach ($dict as $k => $uniq) {
$dict[$k] = '<span id="'.$uniq.'"></span>'; $dict[$k] = phutil_tag('span', array('id' => $uniq), '');
} }
} }

View file

@ -51,7 +51,7 @@ final class DiffusionCommitChangeTableView extends DiffusionView {
), ),
$path); $path);
} else { } else {
$path_column = phutil_escape_html($path); $path_column = $path;
} }
$rows[] = array( $rows[] = array(

View file

@ -107,7 +107,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
} else { } else {
$committer = self::renderName($committer); $committer = self::renderName($committer);
} }
$author .= '/'.$committer; $author = hsprintf('%s/%s', $author, $committer);
} }
$commit = $history->getCommit(); $commit = $history->getCommit();
@ -118,7 +118,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
$path = null, $path = null,
$history->getCommitIdentifier()); $history->getCommitIdentifier());
} else { } else {
$change = "<em>Importing\xE2\x80\xA6</em>"; $change = phutil_tag('em', array(), "Importing\xE2\x80\xA6");
} }
$rows[] = array( $rows[] = array(

View file

@ -79,7 +79,6 @@ final class DiffusionTagListView extends DiffusionView {
$description = $tag->getDescription(); $description = $tag->getDescription();
} }
} }
$description = phutil_escape_html($description);
$rows[] = array( $rows[] = array(
$tag_link, $tag_link,

View file

@ -156,7 +156,7 @@ abstract class DiffusionView extends AphrontView {
), ),
$email->getDisplayName()); $email->getDisplayName());
} }
return phutil_escape_html($name); return hsprintf('%s', $name);
} }
} }

View file

@ -44,7 +44,7 @@ abstract class DrydockController extends PhabricatorController {
'href' => $lease_uri, 'href' => $lease_uri,
), ),
$log->getLeaseID()), $log->getLeaseID()),
phutil_escape_html($log->getMessage()), $log->getMessage(),
phabricator_date($log->getEpoch(), $user), phabricator_date($log->getEpoch(), $user),
); );
} }

View file

@ -32,10 +32,7 @@ final class PhabricatorFactHomeController extends PhabricatorFactController {
$name = $spec->getName(); $name = $spec->getName();
$value = $spec->formatValueForDisplay($user, $fact->getValueX()); $value = $spec->formatValueForDisplay($user, $fact->getValueX());
$rows[] = array( $rows[] = array($name, $value);
phutil_escape_html($name),
phutil_escape_html($value),
);
} }
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);

View file

@ -27,7 +27,7 @@ final class PhabricatorFlagListView extends AphrontView {
), ),
''), ''),
$flag->getHandle()->renderLink(), $flag->getHandle()->renderLink(),
phutil_escape_html($flag->getNote()), $flag->getNote(),
phabricator_datetime($flag->getDateCreated(), $user), phabricator_datetime($flag->getDateCreated(), $user),
phabricator_form( phabricator_form(
$user, $user,

View file

@ -301,8 +301,8 @@ final class HeraldTranscriptController extends HeraldController {
} }
$rows[] = array( $rows[] = array(
phutil_escape_html($action_names[$apply_xscript->getAction()]), $action_names[$apply_xscript->getAction()],
phutil_escape_html($target), $target,
hsprintf( hsprintf(
'<strong>Taken because:</strong> %s<br />'. '<strong>Taken because:</strong> %s<br />'.
'<strong>Outcome:</strong> %s %s', '<strong>Outcome:</strong> %s %s',
@ -487,15 +487,10 @@ final class HeraldTranscriptController extends HeraldController {
'class' => 'herald-field-value-transcript', 'class' => 'herald-field-value-transcript',
), ),
$value); $value);
} else {
$value = phutil_escape_html($value);
} }
} }
$rows[] = array( $rows[] = array($name, $value);
phutil_escape_html($name),
$value,
);
} }
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);

View file

@ -31,8 +31,8 @@ final class PhabricatorMailingListsListController
$rows = array(); $rows = array();
foreach ($lists as $list) { foreach ($lists as $list) {
$rows[] = array( $rows[] = array(
phutil_escape_html($list->getName()), $list->getName(),
phutil_escape_html($list->getEmail()), $list->getEmail(),
phutil_tag( phutil_tag(
'a', 'a',
array( array(

View file

@ -363,9 +363,9 @@ final class ManiphestReportController extends ManiphestController {
$fmt = number_format($delta); $fmt = number_format($delta);
if ($delta > 0) { if ($delta > 0) {
$fmt = '+'.$fmt; $fmt = '+'.$fmt;
$fmt = '<span class="red">'.$fmt.'</span>'; $fmt = hsprintf('<span class="red">%s</span>', $fmt);
} else { } else {
$fmt = '<span class="green">'.$fmt.'</span>'; $fmt = hsprintf('<span class="green">%s</span>', $fmt);
} }
return array( return array(

View file

@ -81,7 +81,7 @@ final class ManiphestSavedQueryListController extends ManiphestController {
'value' => 0, 'value' => 0,
'checked' => ($default === null ? 'checked' : null), 'checked' => ($default === null ? 'checked' : null),
)), )),
'<em>No Default</em>', phutil_tag('em', array(), 'No Default'),
'', '',
'', '',
); );

View file

@ -67,7 +67,7 @@ final class PhabricatorMetaMTAListController
phabricator_datetime($mail->getDateCreated(), $user), phabricator_datetime($mail->getDateCreated(), $user),
phabricator_format_relative_time_detailed( phabricator_format_relative_time_detailed(
time() - $mail->getDateModified()), time() - $mail->getDateModified()),
phutil_escape_html($mail->getSubject()), $mail->getSubject(),
phutil_tag( phutil_tag(
'a', 'a',
array( array(

View file

@ -38,7 +38,7 @@ final class PhabricatorMetaMTAReceivedListController
$mail->getRelatedPHID() $mail->getRelatedPHID()
? $handles[$mail->getRelatedPHID()]->renderLink() ? $handles[$mail->getRelatedPHID()]->renderLink()
: '-', : '-',
phutil_escape_html($mail->getMessage()), $mail->getMessage(),
); );
} }

View file

@ -45,22 +45,19 @@ final class PhabricatorNotificationStatusController
$rows = array(); $rows = array();
foreach ($status as $key => $value) { foreach ($status as $key => $value) {
$label = phutil_escape_html($key);
switch ($key) { switch ($key) {
case 'uptime': case 'uptime':
$value /= 1000; $value /= 1000;
$value = phabricator_format_relative_time_detailed($value); $value = phabricator_format_relative_time_detailed($value);
break; break;
case 'log': case 'log':
$value = phutil_escape_html($value);
break; break;
default: default:
$value = phutil_escape_html(number_format($value)); $value = number_format($value);
break; break;
} }
$rows[] = array($label, $value); $rows[] = array($key, $value);
} }
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);

View file

@ -47,32 +47,25 @@ final class PhabricatorOwnersDetailController
$rows = array(); $rows = array();
$rows[] = array( $rows[] = array('Name', $package->getName());
'Name', $rows[] = array('Description', $package->getDescription());
phutil_escape_html($package->getName()));
$rows[] = array(
'Description',
phutil_escape_html($package->getDescription()));
$primary_owner = null; $primary_owner = null;
$primary_phid = $package->getPrimaryOwnerPHID(); $primary_phid = $package->getPrimaryOwnerPHID();
if ($primary_phid && isset($handles[$primary_phid])) { if ($primary_phid && isset($handles[$primary_phid])) {
$primary_owner = $primary_owner = phutil_tag(
'<strong>'.$handles[$primary_phid]->renderLink().'</strong>'; 'strong',
array(),
$handles[$primary_phid]->renderLink());
} }
$rows[] = array( $rows[] = array('Primary Owner', $primary_owner);
'Primary Owner',
$primary_owner,
);
$owner_links = array(); $owner_links = array();
foreach ($owners as $owner) { foreach ($owners as $owner) {
$owner_links[] = $handles[$owner->getUserPHID()]->renderLink(); $owner_links[] = $handles[$owner->getUserPHID()]->renderLink();
} }
$owner_links = implode('<br />', $owner_links); $owner_links = array_interleave(phutil_tag('br'), $owner_links);
$rows[] = array( $rows[] = array('Owners', $owner_links);
'Owners',
$owner_links);
$rows[] = array( $rows[] = array(
'Auditing', 'Auditing',
@ -99,14 +92,14 @@ final class PhabricatorOwnersDetailController
'href' => (string) $href, 'href' => (string) $href,
), ),
$path->getPath()); $path->getPath());
$path_links[] = $path_links[] = hsprintf(
($path->getExcluded() ? '&ndash;' : '+').' '. '%s %s %s',
$repo_name.' '.$path_link; ($path->getExcluded() ? "\xE2\x80\x93" : '+'),
$repo_name,
$path_link);
} }
$path_links = implode('<br />', $path_links); $path_links = array_interleave(phutil_tag('br'), $path_links);
$rows[] = array( $rows[] = array('Paths', $path_links);
'Paths',
$path_links);
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);
$table->setColumnClasses( $table->setColumnClasses(

View file

@ -235,10 +235,10 @@ final class PhabricatorOwnersListController
foreach ($pkg_owners as $key => $owner) { foreach ($pkg_owners as $key => $owner) {
$pkg_owners[$key] = $handles[$owner->getUserPHID()]->renderLink(); $pkg_owners[$key] = $handles[$owner->getUserPHID()]->renderLink();
if ($owner->getUserPHID() == $package->getPrimaryOwnerPHID()) { if ($owner->getUserPHID() == $package->getPrimaryOwnerPHID()) {
$pkg_owners[$key] = '<strong>'.$pkg_owners[$key].'</strong>'; $pkg_owners[$key] = phutil_tag('strong', array(), $pkg_owners[$key]);
} }
} }
$pkg_owners = implode('<br />', $pkg_owners); $pkg_owners = array_interleave(phutil_tag('br'), $pkg_owners);
$pkg_paths = idx($paths, $package->getID(), array()); $pkg_paths = idx($paths, $package->getID(), array());
foreach ($pkg_paths as $key => $path) { foreach ($pkg_paths as $key => $path) {
@ -251,20 +251,21 @@ final class PhabricatorOwnersListController
'path' => $path->getPath(), 'path' => $path->getPath(),
'action' => 'browse', 'action' => 'browse',
)); ));
$pkg_paths[$key] = $pkg_paths[$key] = hsprintf(
($path->getExcluded() ? '&ndash;' : '+').' '. '%s %s%s',
phutil_tag('strong', array(), $repo->getName()). ($path->getExcluded() ? "\xE2\x80\x93" : '+'),
phutil_tag('strong', array(), $repo->getName()),
phutil_tag( phutil_tag(
'a', 'a',
array( array(
'href' => (string) $href, 'href' => (string) $href,
), ),
$path->getPath()); $path->getPath()));
} else { } else {
$pkg_paths[$key] = phutil_escape_html($path->getPath()); $pkg_paths[$key] = $path->getPath();
} }
} }
$pkg_paths = implode('<br />', $pkg_paths); $pkg_paths = array_interleave(phutil_tag('br'), $pkg_paths);
$rows[] = array( $rows[] = array(
phutil_tag( phutil_tag(

View file

@ -153,34 +153,29 @@ final class PhabricatorPeopleLdapController
private function renderUserInputs($user) { private function renderUserInputs($user) {
$username = $user[0]; $username = $user[0];
$inputs = phutil_tag( return hsprintf(
'input', '%s%s%s',
array( phutil_tag(
'type' => 'checkbox', 'input',
'name' => 'usernames[]', array(
'value' =>$username, 'type' => 'checkbox',
), 'name' => 'usernames[]',
''); 'value' => $username,
)),
$inputs .= phutil_tag( phutil_tag(
'input', 'input',
array( array(
'type' => 'hidden', 'type' => 'hidden',
'name' => "email[$username]", 'name' => "email[$username]",
'value' =>$user[1], 'value' => $user[1],
), )),
''); phutil_tag(
'input',
$inputs .= phutil_tag( array(
'input', 'type' => 'hidden',
array( 'name' => "name[$username]",
'type' => 'hidden', 'value' => $user[2],
'name' => "name[$username]", )));
'value' =>$user[2],
),
'');
return $inputs;
} }
} }

View file

@ -55,7 +55,7 @@ final class PhabricatorPeopleListController
'href' => '/p/'.$user->getUsername().'/', 'href' => '/p/'.$user->getUsername().'/',
), ),
$user->getUserName()), $user->getUserName()),
phutil_escape_html($user->getRealName()), $user->getRealName(),
$status, $status,
$email, $email,
phutil_tag( phutil_tag(

View file

@ -157,10 +157,8 @@ final class PhabricatorPeopleLogsController
phabricator_date($log->getDateCreated(),$user), phabricator_date($log->getDateCreated(),$user),
phabricator_time($log->getDateCreated(),$user), phabricator_time($log->getDateCreated(),$user),
$log->getAction(), $log->getAction(),
$log->getActorPHID() $log->getActorPHID() ? $handles[$log->getActorPHID()]->getName() : null,
? phutil_escape_html($handles[$log->getActorPHID()]->getName()) $handles[$log->getUserPHID()]->getName(),
: null,
phutil_escape_html($handles[$log->getUserPHID()]->getName()),
json_encode($log->getOldValue(), true), json_encode($log->getOldValue(), true),
json_encode($log->getNewValue(), true), json_encode($log->getNewValue(), true),
phutil_tag( phutil_tag(

View file

@ -24,9 +24,9 @@ final class PhabricatorPHIDLookupController
} }
$rows[] = array( $rows[] = array(
phutil_escape_html($handle->getPHID()), $handle->getPHID(),
phutil_escape_html($handle->getType()), $handle->getType(),
phutil_escape_html($handle->getName()), $handle->getName(),
$link, $link,
); );
} }

View file

@ -234,9 +234,9 @@ final class PhrictionDiffController
$rows[] = array( $rows[] = array(
phabricator_date($c->getDateCreated(), $user), phabricator_date($c->getDateCreated(), $user),
phabricator_time($c->getDateCreated(), $user), phabricator_time($c->getDateCreated(), $user),
phutil_escape_html('Version '.$c->getVersion()), 'Version '.$c->getVersion(),
$handles[$c->getAuthorPHID()]->renderLink(), $handles[$c->getAuthorPHID()]->renderLink(),
phutil_escape_html($c->getDescription()), $c->getDescription(),
); );
} }

View file

@ -49,7 +49,7 @@ final class PhrictionHistoryController
$diff_uri = new PhutilURI('/phriction/diff/'.$document->getID().'/'); $diff_uri = new PhutilURI('/phriction/diff/'.$document->getID().'/');
$vs_previous = '<em>'.pht('Created').'</em>'; $vs_previous = phutil_tag('em', array(), pht('Created'));
if ($content->getVersion() != 1) { if ($content->getVersion() != 1) {
$uri = $diff_uri $uri = $diff_uri
->alter('l', $content->getVersion() - 1) ->alter('l', $content->getVersion() - 1)
@ -62,7 +62,7 @@ final class PhrictionHistoryController
pht('Show Change')); pht('Show Change'));
} }
$vs_head = '<em>'.pht('Current').'</em>'; $vs_head = phutil_tag('em', array(), pht('Current'));
if ($content->getID() != $document->getContentID()) { if ($content->getID() != $document->getContentID()) {
$uri = $diff_uri $uri = $diff_uri
->alter('l', $content->getVersion()) ->alter('l', $content->getVersion())
@ -90,7 +90,7 @@ final class PhrictionHistoryController
pht('Version %s', $version)), pht('Version %s', $version)),
$handles[$content->getAuthorPHID()]->renderLink(), $handles[$content->getAuthorPHID()]->renderLink(),
$change_type, $change_type,
phutil_escape_html($content->getDescription()), $content->getDescription(),
$vs_previous, $vs_previous,
$vs_head, $vs_head,
); );

View file

@ -106,10 +106,9 @@ final class PhabricatorProjectListController
'href' => '/project/view/'.$project->getID().'/', 'href' => '/project/view/'.$project->getID().'/',
), ),
$project->getName()), $project->getName()),
phutil_escape_html( PhabricatorProjectStatus::getNameForStatus($project->getStatus()),
PhabricatorProjectStatus::getNameForStatus($project->getStatus())), $blurb,
phutil_escape_html($blurb), $population,
phutil_escape_html($population),
phutil_tag( phutil_tag(
'a', 'a',
array( array(

View file

@ -27,12 +27,12 @@ final class PhabricatorRepositoryListController
), ),
'View in Diffusion'); 'View in Diffusion');
} else { } else {
$diffusion_link = '<em>Not Tracked</em>'; $diffusion_link = phutil_tag('em', array(), 'Not Tracked');
} }
$rows[] = array( $rows[] = array(
phutil_escape_html($repo->getCallsign()), $repo->getCallsign(),
phutil_escape_html($repo->getName()), $repo->getName(),
PhabricatorRepositoryType::getNameForRepositoryType( PhabricatorRepositoryType::getNameForRepositoryType(
$repo->getVersionControlSystem()), $repo->getVersionControlSystem()),
$diffusion_link, $diffusion_link,
@ -98,13 +98,13 @@ final class PhabricatorRepositoryListController
foreach ($projects as $project) { foreach ($projects as $project) {
$repo = idx($repos, $project->getRepositoryID()); $repo = idx($repos, $project->getRepositoryID());
if ($repo) { if ($repo) {
$repo_name = phutil_escape_html($repo->getName()); $repo_name = $repo->getName();
} else { } else {
$repo_name = '-'; $repo_name = '-';
} }
$rows[] = array( $rows[] = array(
phutil_escape_html($project->getName()), $project->getName(),
$repo_name, $repo_name,
phutil_tag( phutil_tag(
'a', 'a',

View file

@ -103,7 +103,7 @@ final class PhabricatorSettingsPanelEmailAddresses
} }
$rows[] = array( $rows[] = array(
phutil_escape_html($email->getAddress()), $email->getAddress(),
$action, $action,
$remove, $remove,
); );

View file

@ -182,8 +182,8 @@ final class PhabricatorSettingsPanelSSHKeys
'href' => $this->getPanelURI('?edit='.$key->getID()), 'href' => $this->getPanelURI('?edit='.$key->getID()),
), ),
$key->getName()), $key->getName()),
phutil_escape_html($key->getKeyComment()), $key->getKeyComment(),
phutil_escape_html($key->getKeyType()), $key->getKeyType(),
phabricator_date($key->getDateCreated(), $user), phabricator_date($key->getDateCreated(), $user),
phabricator_time($key->getDateCreated(), $user), phabricator_time($key->getDateCreated(), $user),
javelin_tag( javelin_tag(

View file

@ -297,9 +297,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
$rows = array(); $rows = array();
foreach ($results as $result) { foreach ($results as $result) {
$wire = $result->getWireFormat(); $wire = $result->getWireFormat();
foreach ($wire as $k => $v) {
$wire[$k] = phutil_escape_html($v);
}
$rows[] = $wire; $rows[] = $wire;
} }

View file

@ -21,7 +21,7 @@ final class AphrontJavelinView extends AphrontView {
public function render() { public function render() {
$id = celerity_generate_unique_node_id(); $id = celerity_generate_unique_node_id();
$placeholder = "<span id={$id} />"; $placeholder = phutil_tag('span', array('id' => $id));
require_celerity_resource($this->getCelerityResource()); require_celerity_resource($this->getCelerityResource());

View file

@ -111,18 +111,7 @@ final class AphrontTableView extends AphrontView {
public function render() { public function render() {
require_celerity_resource('aphront-table-view-css'); require_celerity_resource('aphront-table-view-css');
$table_class = $this->className; $table = array();
if ($this->deviceReadyTable) {
$table_class .= ' aphront-table-view-device-ready';
}
if ($table_class !== null) {
$table_class = ' class="aphront-table-view '.$table_class.'"';
} else {
$table_class = ' class="aphront-table-view"';
}
$table = array('<table'.$table_class.'>');
$col_classes = array(); $col_classes = array();
foreach ($this->columnClasses as $key => $class) { foreach ($this->columnClasses as $key => $class) {
@ -151,7 +140,8 @@ final class AphrontTableView extends AphrontView {
while (count($headers) > count($sort_values)) { while (count($headers) > count($sort_values)) {
$sort_values[] = null; $sort_values[] = null;
} }
$table[] = '<tr>';
$tr = array();
foreach ($headers as $col_num => $header) { foreach ($headers as $col_num => $header) {
if (!$visibility[$col_num]) { if (!$visibility[$col_num]) {
continue; continue;
@ -202,7 +192,7 @@ final class AphrontTableView extends AphrontView {
} }
if ($classes) { if ($classes) {
$class = ' class="'.implode(' ', $classes).'"'; $class = implode(' ', $classes);
} else { } else {
$class = null; $class = null;
} }
@ -221,12 +211,12 @@ final class AphrontTableView extends AphrontView {
), ),
$short_headers[$col_num]); $short_headers[$col_num]);
$header = $header_nodevice.$header_device; $header = hsprintf('%s %s', $header_nodevice, $header_device);
} }
$table[] = '<th'.$class.'>'.$header.'</th>'; $tr[] = phutil_tag('th', array('class' => $class), $header);
} }
$table[] = '</tr>'; $table[] = phutil_tag('tr', array(), $tr);
} }
foreach ($col_classes as $key => $value) { foreach ($col_classes as $key => $value) {
@ -251,18 +241,7 @@ final class AphrontTableView extends AphrontView {
while (count($row) > count($visibility)) { while (count($row) > count($visibility)) {
$visibility[] = true; $visibility[] = true;
} }
$class = idx($this->rowClasses, $row_num); $tr = array();
if ($this->zebraStripes && ($row_num % 2)) {
if ($class !== null) {
$class = 'alt alt-'.$class;
} else {
$class = 'alt';
}
}
if ($class !== null) {
$class = ' class="'.$class.'"';
}
$table[] = '<tr'.$class.'>';
// NOTE: Use of a separate column counter is to allow this to work // NOTE: Use of a separate column counter is to allow this to work
// correctly if the row data has string or non-sequential keys. // correctly if the row data has string or non-sequential keys.
$col_num = 0; $col_num = 0;
@ -275,26 +254,40 @@ final class AphrontTableView extends AphrontView {
if (!empty($this->cellClasses[$row_num][$col_num])) { if (!empty($this->cellClasses[$row_num][$col_num])) {
$class = trim($class.' '.$this->cellClasses[$row_num][$col_num]); $class = trim($class.' '.$this->cellClasses[$row_num][$col_num]);
} }
if ($class !== null) { $tr[] = phutil_tag('td', array('class' => $class), $value);
$table[] = '<td class="'.$class.'">';
} else {
$table[] = '<td>';
}
$table[] = $value.'</td>';
++$col_num; ++$col_num;
} }
$class = idx($this->rowClasses, $row_num);
if ($this->zebraStripes && ($row_num % 2)) {
if ($class !== null) {
$class = 'alt alt-'.$class;
} else {
$class = 'alt';
}
}
$table[] = phutil_tag('tr', array('class' => $class), $tr);
++$row_num; ++$row_num;
} }
} else { } else {
$colspan = max(count(array_filter($visibility)), 1); $colspan = max(count(array_filter($visibility)), 1);
$table[] = $table[] = hsprintf(
'<tr class="no-data"><td colspan="'.$colspan.'">'. '<tr class="no-data"><td colspan="%s">%s</td></tr>',
coalesce($this->noDataString, 'No data available.'). $colspan,
'</td></tr>'; coalesce($this->noDataString, 'No data available.'));
} }
$table[] = '</table>';
$html = implode('', $table); $table_class = 'aphront-table-view';
return '<div class="aphront-table-wrap">'.$html.'</div>'; if ($this->className !== null) {
$table_class .= ' '.$this->className;
}
if ($this->deviceReadyTable) {
$table_class .= ' aphront-table-view-device-ready';
}
$html = phutil_tag('table', array('class' => $table_class), $table);
return hsprintf('<div class="aphront-table-wrap">%s</div>', $html);
} }
public static function renderSingleDisplayLine($line) { public static function renderSingleDisplayLine($line) {