Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/differential/field/specification/DifferentialLintFieldSpecification.php b/src/applications/differential/field/specification/DifferentialLintFieldSpecification.php
index 2c0164a255..b773e38580 100644
--- a/src/applications/differential/field/specification/DifferentialLintFieldSpecification.php
+++ b/src/applications/differential/field/specification/DifferentialLintFieldSpecification.php
@@ -1,268 +1,271 @@
<?php
final class DifferentialLintFieldSpecification
extends DifferentialFieldSpecification {
public function shouldAppearOnDiffView() {
return true;
}
public function renderLabelForDiffView() {
return $this->renderLabelForRevisionView();
}
public function renderValueForDiffView() {
return $this->renderValueForRevisionView();
}
public function shouldAppearOnRevisionView() {
return true;
}
public function renderLabelForRevisionView() {
return 'Lint:';
}
private function getLintExcuse() {
return $this->getDiffProperty('arc:lint-excuse');
}
private function getPostponedLinters() {
return $this->getDiffProperty('arc:lint-postponed');
}
public function renderValueForRevisionView() {
$diff = $this->getManualDiff();
$path_changesets = mpull($diff->loadChangesets(), 'getID', 'getFilename');
$lstar = DifferentialRevisionUpdateHistoryView::renderDiffLintStar($diff);
$lmsg = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff);
$ldata = $this->getDiffProperty('arc:lint');
$ltail = null;
$rows = array();
$rows[] = array(
'style' => 'star',
- 'name' => $lstar,
+ 'name' => phutil_safe_html($lstar),
'value' => $lmsg,
'show' => true,
);
$excuse = $this->getLintExcuse();
if ($excuse) {
$rows[] = array(
'style' => 'excuse',
'name' => 'Excuse',
- 'value' => nl2br(phutil_escape_html($excuse)),
+ 'value' => phutil_safe_html(nl2br(phutil_escape_html($excuse))),
'show' => true,
);
}
$show_limit = 10;
$hidden = array();
if ($ldata) {
$ldata = igroup($ldata, 'path');
foreach ($ldata as $path => $messages) {
$rows[] = array(
'style' => 'section',
- 'name' => phutil_escape_html($path),
+ 'name' => $path,
'show' => $show_limit,
);
foreach ($messages as $message) {
$path = idx($message, 'path');
$line = idx($message, 'line');
$code = idx($message, 'code');
$severity = idx($message, 'severity');
$name = idx($message, 'name');
$description = idx($message, 'description');
$line_link = 'line '.intval($line);
if (isset($path_changesets[$path])) {
$href = '#C'.$path_changesets[$path].'NL'.max(1, $line);
if ($diff->getID() != $this->getDiff()->getID()) {
$href = '/D'.$diff->getRevisionID().'?id='.$diff->getID().$href;
}
$line_link = phutil_tag(
'a',
array(
'href' => $href,
),
$line_link);
}
if ($show_limit) {
--$show_limit;
$show = true;
} else {
$show = false;
if (empty($hidden[$severity])) {
$hidden[$severity] = 0;
}
$hidden[$severity]++;
}
$rows[] = array(
'style' => $this->getSeverityStyle($severity),
- 'name' => phutil_escape_html(ucwords($severity)),
+ 'name' => ucwords($severity),
'value' => hsprintf(
"(%s) %s at {$line_link}",
$code,
$name),
'show' => $show,
);
if (isset($message['locations'])) {
$locations = array();
foreach ($message['locations'] as $location) {
$other_line = idx($location, 'line');
$locations[] =
idx($location, 'path', $path).
($other_line ? ":{$other_line}" : "");
}
$description .= "\nOther locations: ".implode(", ", $locations);
}
if (strlen($description)) {
$rows[] = array(
'style' => 'details',
- 'value' => nl2br(phutil_escape_html($description)),
+ 'value' =>
+ phutil_safe_html(
+ nl2br(
+ phutil_escape_html($description))),
'show' => false,
);
if (empty($hidden['details'])) {
$hidden['details'] = 0;
}
$hidden['details']++;
}
}
}
}
$postponed = $this->getPostponedLinters();
if ($postponed) {
foreach ($postponed as $linter) {
$rows[] = array(
'style' => $this->getPostponedStyle(),
'name' => 'Postponed',
- 'value' => phutil_escape_html($linter),
+ 'value' => $linter,
'show' => false,
);
if (empty($hidden['postponed'])) {
$hidden['postponed'] = 0;
}
$hidden['postponed']++;
}
}
$show_string = $this->renderShowString($hidden);
$view = new DifferentialResultsTableView();
$view->setRows($rows);
$view->setShowMoreString($show_string);
return $view->render();
}
private function getSeverityStyle($severity) {
$map = array(
ArcanistLintSeverity::SEVERITY_ERROR => 'red',
ArcanistLintSeverity::SEVERITY_WARNING => 'yellow',
ArcanistLintSeverity::SEVERITY_AUTOFIX => 'yellow',
ArcanistLintSeverity::SEVERITY_ADVICE => 'yellow',
);
return idx($map, $severity);
}
private function getPostponedStyle() {
return 'blue';
}
private function renderShowString(array $hidden) {
if (!$hidden) {
return null;
}
// Reorder hidden things by severity.
$hidden = array_select_keys(
$hidden,
array(
ArcanistLintSeverity::SEVERITY_ERROR,
ArcanistLintSeverity::SEVERITY_WARNING,
ArcanistLintSeverity::SEVERITY_AUTOFIX,
ArcanistLintSeverity::SEVERITY_ADVICE,
'details',
'postponed',
)) + $hidden;
$show = array();
foreach ($hidden as $key => $value) {
switch ($key) {
case ArcanistLintSeverity::SEVERITY_ERROR:
$show[] = pht('%d Error(s)', $value);
break;
case ArcanistLintSeverity::SEVERITY_WARNING:
$show[] = pht('%d Warning(s)', $value);
break;
case ArcanistLintSeverity::SEVERITY_AUTOFIX:
$show[] = pht('%d Auto-Fix(es)', $value);
break;
case ArcanistLintSeverity::SEVERITY_ADVICE:
$show[] = pht('%d Advice(s)', $value);
break;
case 'details':
$show[] = pht('%d Detail(s)', $value);
break;
case 'postponed':
$show[] = pht('%d Postponed', $value);
break;
default:
$show[] = $value;
break;
}
}
return "Show Full Lint Results (".implode(', ', $show).")";
}
public function renderWarningBoxForRevisionAccept() {
$status = $this->getDiff()->getLintStatus();
if ($status < DifferentialLintStatus::LINT_WARN) {
return null;
}
$severity = AphrontErrorView::SEVERITY_ERROR;
$titles = array(
DifferentialLintStatus::LINT_WARN => 'Lint Warning',
DifferentialLintStatus::LINT_FAIL => 'Lint Failure',
DifferentialLintStatus::LINT_SKIP => 'Lint Skipped',
DifferentialLintStatus::LINT_POSTPONED => 'Lint Postponed',
);
if ($status == DifferentialLintStatus::LINT_SKIP) {
$content =
"<p>This diff was created without running lint. Make sure you are ".
"OK with that before you accept this diff.</p>";
} else if ($status == DifferentialLintStatus::LINT_POSTPONED) {
$severity = AphrontErrorView::SEVERITY_WARNING;
$content =
"<p>Postponed linters didn't finish yet. Make sure you are OK with ".
"that before you accept this diff.</p>";
} else {
$content =
"<p>This diff has Lint Problems. Make sure you are OK with them ".
"before you accept this diff.</p>";
}
return id(new AphrontErrorView())
->setSeverity($severity)
->appendChild($content)
->setTitle(idx($titles, $status, 'Warning'));
}
}
diff --git a/src/applications/differential/field/specification/DifferentialUnitFieldSpecification.php b/src/applications/differential/field/specification/DifferentialUnitFieldSpecification.php
index 348964045c..b19ae2f798 100644
--- a/src/applications/differential/field/specification/DifferentialUnitFieldSpecification.php
+++ b/src/applications/differential/field/specification/DifferentialUnitFieldSpecification.php
@@ -1,223 +1,223 @@
<?php
final class DifferentialUnitFieldSpecification
extends DifferentialFieldSpecification {
public function shouldAppearOnDiffView() {
return true;
}
public function renderLabelForDiffView() {
return $this->renderLabelForRevisionView();
}
public function renderValueForDiffView() {
return $this->renderValueForRevisionView();
}
public function shouldAppearOnRevisionView() {
return true;
}
public function renderLabelForRevisionView() {
return 'Unit:';
}
private function getUnitExcuse() {
return $this->getDiffProperty('arc:unit-excuse');
}
public function renderValueForRevisionView() {
$diff = $this->getManualDiff();
$ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff);
$umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
$rows = array();
$rows[] = array(
'style' => 'star',
- 'name' => $ustar,
+ 'name' => phutil_safe_html($ustar),
'value' => $umsg,
'show' => true,
);
$excuse = $this->getUnitExcuse();
if ($excuse) {
$rows[] = array(
'style' => 'excuse',
'name' => 'Excuse',
- 'value' => nl2br(phutil_escape_html($excuse)),
+ 'value' => phutil_safe_html(nl2br(phutil_escape_html($excuse))),
'show' => true,
);
}
$show_limit = 10;
$hidden = array();
$udata = $this->getDiffProperty('arc:unit');
if ($udata) {
$sort_map = array(
ArcanistUnitTestResult::RESULT_BROKEN => 0,
ArcanistUnitTestResult::RESULT_FAIL => 1,
ArcanistUnitTestResult::RESULT_UNSOUND => 2,
ArcanistUnitTestResult::RESULT_SKIP => 3,
ArcanistUnitTestResult::RESULT_POSTPONED => 4,
ArcanistUnitTestResult::RESULT_PASS => 5,
);
foreach ($udata as $key => $test) {
$udata[$key]['sort'] = idx($sort_map, idx($test, 'result'));
}
$udata = isort($udata, 'sort');
foreach ($udata as $test) {
$result = idx($test, 'result');
$default_hide = false;
switch ($result) {
case ArcanistUnitTestResult::RESULT_POSTPONED:
case ArcanistUnitTestResult::RESULT_PASS:
$default_hide = true;
break;
}
if ($show_limit && !$default_hide) {
--$show_limit;
$show = true;
} else {
$show = false;
if (empty($hidden[$result])) {
$hidden[$result] = 0;
}
$hidden[$result]++;
}
$value = idx($test, 'name');
if (!empty($test['link'])) {
$value = phutil_tag(
'a',
array(
'href' => $test['link'],
'target' => '_blank',
),
$value);
}
$rows[] = array(
'style' => $this->getResultStyle($result),
- 'name' => phutil_escape_html(ucwords($result)),
+ 'name' => ucwords($result),
'value' => $value,
'show' => $show,
);
$userdata = idx($test, 'userdata');
if ($userdata) {
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$userdata = phutil_safe_html($engine->markupText($userdata));
$rows[] = array(
'style' => 'details',
'value' => $userdata,
'show' => false,
);
if (empty($hidden['details'])) {
$hidden['details'] = 0;
}
$hidden['details']++;
}
}
}
$show_string = $this->renderShowString($hidden);
$view = new DifferentialResultsTableView();
$view->setRows($rows);
$view->setShowMoreString($show_string);
return $view->render();
}
private function getResultStyle($result) {
$map = array(
ArcanistUnitTestResult::RESULT_PASS => 'green',
ArcanistUnitTestResult::RESULT_FAIL => 'red',
ArcanistUnitTestResult::RESULT_SKIP => 'blue',
ArcanistUnitTestResult::RESULT_BROKEN => 'red',
ArcanistUnitTestResult::RESULT_UNSOUND => 'yellow',
ArcanistUnitTestResult::RESULT_POSTPONED => 'blue',
);
return idx($map, $result);
}
private function renderShowString(array $hidden) {
if (!$hidden) {
return null;
}
// Reorder hidden things by severity.
$hidden = array_select_keys(
$hidden,
array(
ArcanistUnitTestResult::RESULT_BROKEN,
ArcanistUnitTestResult::RESULT_FAIL,
ArcanistUnitTestResult::RESULT_UNSOUND,
ArcanistUnitTestResult::RESULT_SKIP,
ArcanistUnitTestResult::RESULT_POSTPONED,
ArcanistUnitTestResult::RESULT_PASS,
'details',
)) + $hidden;
$noun = array(
ArcanistUnitTestResult::RESULT_BROKEN => 'Broken',
ArcanistUnitTestResult::RESULT_FAIL => 'Failed',
ArcanistUnitTestResult::RESULT_UNSOUND => 'Unsound',
ArcanistUnitTestResult::RESULT_SKIP => 'Skipped',
ArcanistUnitTestResult::RESULT_POSTPONED => 'Postponed',
ArcanistUnitTestResult::RESULT_PASS => 'Passed',
);
$show = array();
foreach ($hidden as $key => $value) {
if ($key == 'details') {
$show[] = pht('%d Detail(s)', $value);
} else {
$show[] = $value.' '.idx($noun, $key);
}
}
return "Show Full Unit Results (".implode(', ', $show).")";
}
public function renderWarningBoxForRevisionAccept() {
$diff = $this->getDiff();
$unit_warning = null;
if ($diff->getUnitStatus() >= DifferentialUnitStatus::UNIT_WARN) {
$titles =
array(
DifferentialUnitStatus::UNIT_WARN => 'Unit Tests Warning',
DifferentialUnitStatus::UNIT_FAIL => 'Unit Tests Failure',
DifferentialUnitStatus::UNIT_SKIP => 'Unit Tests Skipped',
DifferentialUnitStatus::UNIT_POSTPONED => 'Unit Tests Postponed'
);
if ($diff->getUnitStatus() == DifferentialUnitStatus::UNIT_POSTPONED) {
$content =
"<p>This diff has postponed unit tests. The results should be ".
"coming in soon. You should probably wait for them before accepting ".
"this diff.</p>";
} else if ($diff->getUnitStatus() == DifferentialUnitStatus::UNIT_SKIP) {
$content =
"<p>Unit tests were skipped when this diff was created. Make sure ".
"you are OK with that before you accept this diff.</p>";
} else {
$content =
"<p>This diff has Unit Test Problems. Make sure you are OK with ".
"them before you accept this diff.</p>";
}
$unit_warning = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_ERROR)
->appendChild($content)
->setTitle(idx($titles, $diff->getUnitStatus(), 'Warning'));
}
return $unit_warning;
}
}
diff --git a/src/applications/differential/view/DifferentialResultsTableView.php b/src/applications/differential/view/DifferentialResultsTableView.php
index 46c8595968..519c9319f1 100644
--- a/src/applications/differential/view/DifferentialResultsTableView.php
+++ b/src/applications/differential/view/DifferentialResultsTableView.php
@@ -1,115 +1,115 @@
<?php
final class DifferentialResultsTableView extends AphrontView {
private $rows;
private $showMoreString;
public function setRows(array $rows) {
$this->rows = $rows;
return $this;
}
public function setShowMoreString($show_more_string) {
$this->showMoreString = $show_more_string;
return $this;
}
public function render() {
$rows = array();
$any_hidden = false;
foreach ($this->rows as $row) {
$style = idx($row, 'style');
switch ($style) {
case 'section':
- $cells = phutil_render_tag(
+ $cells = phutil_tag(
'th',
array(
'colspan' => 2,
),
idx($row, 'name'));
break;
default:
- $name = phutil_render_tag(
+ $name = phutil_tag(
'th',
array(
),
idx($row, 'name'));
- $value = phutil_render_tag(
+ $value = phutil_tag(
'td',
array(
),
idx($row, 'value'));
- $cells = $name.$value;
+ $cells = array($name, $value);
break;
}
$show = idx($row, 'show');
- $rows[] = javelin_render_tag(
+ $rows[] = javelin_tag(
'tr',
array(
'style' => $show ? null : 'display: none',
'sigil' => $show ? null : 'differential-results-row-toggle',
'class' => 'differential-results-row-'.$style,
),
$cells);
if (!$show) {
$any_hidden = true;
}
}
if ($any_hidden) {
- $show_more = javelin_render_tag(
+ $show_more = javelin_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
),
$this->showMoreString);
- $hide_more = javelin_render_tag(
+ $hide_more = javelin_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
),
'Hide');
- $rows[] = javelin_render_tag(
+ $rows[] = javelin_tag(
'tr',
array(
'class' => 'differential-results-row-show',
'sigil' => 'differential-results-row-show',
),
- '<th colspan="2">'.$show_more.'</td>');
+ phutil_tag('th', array('colspan' => 2), $show_more));
- $rows[] = javelin_render_tag(
+ $rows[] = javelin_tag(
'tr',
array(
'class' => 'differential-results-row-show',
'sigil' => 'differential-results-row-hide',
'style' => 'display: none',
),
- '<th colspan="2">'.$hide_more.'</th>');
+ phutil_tag('th', array('colspan' => 2), $hide_more));
Javelin::initBehavior('differential-show-field-details');
}
require_celerity_resource('differential-results-table-css');
return javelin_render_tag(
'table',
array(
'class' => 'differential-results-table',
'sigil' => 'differential-results-table',
),
implode("\n", $rows));
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Nov 14, 2:06 AM (22 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
336709
Default Alt Text
(19 KB)

Event Timeline