mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 07:12:41 +01:00
Fix most timeline escaping
Summary: Some content might be broken but it's hard to test since JS/Ajax is also a bit broken. Test Plan: Looked at timeline examples. Reviewers: vrana Reviewed By: vrana CC: aran Maniphest Tasks: T2432 Differential Revision: https://secure.phabricator.com/D4683
This commit is contained in:
parent
d83257c29a
commit
47f2df5f51
4 changed files with 49 additions and 31 deletions
|
@ -98,13 +98,13 @@ final class PhabricatorTimelineExample extends PhabricatorUIExample {
|
|||
|
||||
$events[] = id(new PhabricatorTimelineEventView())
|
||||
->setUserHandle($handle)
|
||||
->setTitle(phutil_escape_html("Colorless"))
|
||||
->setTitle("Colorless")
|
||||
->setIcon('lock');
|
||||
|
||||
foreach ($colors as $color) {
|
||||
$events[] = id(new PhabricatorTimelineEventView())
|
||||
->setUserHandle($handle)
|
||||
->setTitle(phutil_escape_html("Color '{$color}'"))
|
||||
->setTitle("Color '{$color}'")
|
||||
->setIcon('lock')
|
||||
->setColor($color);
|
||||
}
|
||||
|
|
|
@ -74,6 +74,19 @@ abstract class AphrontView extends Phobject {
|
|||
}
|
||||
}
|
||||
|
||||
final protected function isEmptyContent($content) {
|
||||
if (is_array($content)) {
|
||||
foreach ($content as $element) {
|
||||
if (!$this->isEmptyContent($element)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return !strlen((string)$content);
|
||||
}
|
||||
}
|
||||
|
||||
abstract public function render();
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ final class PhabricatorAnchorView extends AphrontView {
|
|||
),
|
||||
'');
|
||||
|
||||
return $marker.$anchor;
|
||||
return $this->renderHTMLView(array($marker, $anchor));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,10 +100,10 @@ final class PhabricatorTimelineEventView extends AphrontView {
|
|||
}
|
||||
|
||||
public function render() {
|
||||
$content = $this->renderChildren();
|
||||
$content = $this->renderHTMLChildren();
|
||||
|
||||
$title = $this->title;
|
||||
if (($title === null) && !strlen($content)) {
|
||||
if (($title === null) && $this->isEmptyContent($content)) {
|
||||
$title = '';
|
||||
}
|
||||
|
||||
|
@ -131,14 +131,14 @@ final class PhabricatorTimelineEventView extends AphrontView {
|
|||
''));
|
||||
}
|
||||
|
||||
$title = phutil_render_tag(
|
||||
$title = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => implode(' ', $title_classes),
|
||||
),
|
||||
$title.$extra);
|
||||
array($title, $extra));
|
||||
|
||||
$title = $icon.$title;
|
||||
$title = $this->renderHTMLView(array($icon, $title));
|
||||
}
|
||||
|
||||
$wedge = phutil_tag(
|
||||
|
@ -165,32 +165,34 @@ final class PhabricatorTimelineEventView extends AphrontView {
|
|||
$classes[] = 'phabricator-timeline-border';
|
||||
if ($content) {
|
||||
$classes[] = 'phabricator-timeline-major-event';
|
||||
$content = phutil_render_tag(
|
||||
$content = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => implode(' ', $content_classes),
|
||||
),
|
||||
phutil_render_tag(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-timeline-inner-content',
|
||||
),
|
||||
$title.
|
||||
phutil_render_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-timeline-core-content',
|
||||
),
|
||||
$content)));
|
||||
$content = $image.$wedge.$content;
|
||||
array(
|
||||
$title,
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-timeline-core-content',
|
||||
),
|
||||
$content),
|
||||
)));
|
||||
$content = array($image, $wedge, $content);
|
||||
} else {
|
||||
$classes[] = 'phabricator-timeline-minor-event';
|
||||
$content = phutil_render_tag(
|
||||
$content = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => implode(' ', $content_classes),
|
||||
),
|
||||
$image.$wedge.$title);
|
||||
array($image, $wedge, $title));
|
||||
}
|
||||
|
||||
$outer_classes = $this->classes;
|
||||
|
@ -209,7 +211,7 @@ final class PhabricatorTimelineEventView extends AphrontView {
|
|||
);
|
||||
}
|
||||
|
||||
return javelin_render_tag(
|
||||
return javelin_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => implode(' ', $outer_classes),
|
||||
|
@ -217,7 +219,7 @@ final class PhabricatorTimelineEventView extends AphrontView {
|
|||
'sigil' => $sigil,
|
||||
'meta' => $meta,
|
||||
),
|
||||
phutil_render_tag(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => implode(' ', $classes),
|
||||
|
@ -273,25 +275,28 @@ final class PhabricatorTimelineEventView extends AphrontView {
|
|||
->setAnchorName($this->anchor)
|
||||
->render();
|
||||
|
||||
$date = $anchor.phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '#'.$this->anchor,
|
||||
),
|
||||
$date);
|
||||
$date = $this->renderHTMLView(
|
||||
array(
|
||||
$anchor,
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '#'.$this->anchor,
|
||||
),
|
||||
$date),
|
||||
));
|
||||
}
|
||||
$extra[] = $date;
|
||||
}
|
||||
}
|
||||
|
||||
$extra = implode(' · ', $extra);
|
||||
if ($extra) {
|
||||
$extra = phutil_render_tag(
|
||||
$extra = phutil_tag(
|
||||
'span',
|
||||
array(
|
||||
'class' => 'phabricator-timeline-extra',
|
||||
),
|
||||
$extra);
|
||||
array_interleave(" \xC2\xB7 ", $extra));
|
||||
}
|
||||
|
||||
return $extra;
|
||||
|
|
Loading…
Reference in a new issue