mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Fix two global search issues
Summary: Fixes T8016. - Don't explode on bad UTF8, if we happen to get some for whatever reason. - Don't put `<strong>` tags in the "title" attribute. Test Plan: Faked bad UTF8, no fatal. Hovered titles, no `<strong>` tags. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T8016 Differential Revision: https://secure.phabricator.com/D12710
This commit is contained in:
parent
f311f3f910
commit
c5a734073d
2 changed files with 24 additions and 4 deletions
|
@ -31,12 +31,12 @@ final class PhabricatorSearchResultView extends AphrontView {
|
||||||
|
|
||||||
$type_name = nonempty($handle->getTypeName(), pht('Document'));
|
$type_name = nonempty($handle->getTypeName(), pht('Document'));
|
||||||
|
|
||||||
$title = $this->emboldenQuery($handle->getFullName());
|
$raw_title = $handle->getFullName();
|
||||||
if ($handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
|
$title = $this->emboldenQuery($raw_title);
|
||||||
}
|
|
||||||
|
|
||||||
$item = id(new PHUIObjectItemView())
|
$item = id(new PHUIObjectItemView())
|
||||||
->setHeader($title)
|
->setHeader($title)
|
||||||
|
->setTitleText($raw_title)
|
||||||
->setHref($handle->getURI())
|
->setHref($handle->getURI())
|
||||||
->setImageURI($handle->getImageURI())
|
->setImageURI($handle->getImageURI())
|
||||||
->addAttribute($type_name);
|
->addAttribute($type_name);
|
||||||
|
@ -110,6 +110,9 @@ final class PhabricatorSearchResultView extends AphrontView {
|
||||||
$buf = '';
|
$buf = '';
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
$is_bold = false;
|
$is_bold = false;
|
||||||
|
|
||||||
|
// Make sure this is UTF8 because phutil_utf8v() will explode if it isn't.
|
||||||
|
$str = phutil_utf8ize($str);
|
||||||
foreach (phutil_utf8v($str) as $chr) {
|
foreach (phutil_utf8v($str) as $chr) {
|
||||||
if ($bold[$pos] != $is_bold) {
|
if ($bold[$pos] != $is_bold) {
|
||||||
if (strlen($buf)) {
|
if (strlen($buf)) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
||||||
private $state;
|
private $state;
|
||||||
private $fontIcon;
|
private $fontIcon;
|
||||||
private $imageIcon;
|
private $imageIcon;
|
||||||
|
private $titleText;
|
||||||
|
|
||||||
const AGE_FRESH = 'fresh';
|
const AGE_FRESH = 'fresh';
|
||||||
const AGE_STALE = 'stale';
|
const AGE_STALE = 'stale';
|
||||||
|
@ -98,6 +99,15 @@ final class PHUIObjectItemView extends AphrontTagView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setTitleText($title_text) {
|
||||||
|
$this->titleText = $title_text;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitleText() {
|
||||||
|
return $this->titleText;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHeader() {
|
public function getHeader() {
|
||||||
return $this->header;
|
return $this->header;
|
||||||
}
|
}
|
||||||
|
@ -329,12 +339,19 @@ final class PHUIObjectItemView extends AphrontTagView {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$title_text = null;
|
||||||
|
if ($this->titleText) {
|
||||||
|
$title_text = $this->titleText;
|
||||||
|
} else if ($this->href) {
|
||||||
|
$title_text = $this->header;
|
||||||
|
}
|
||||||
|
|
||||||
$header_link = phutil_tag(
|
$header_link = phutil_tag(
|
||||||
$this->href ? 'a' : 'div',
|
$this->href ? 'a' : 'div',
|
||||||
array(
|
array(
|
||||||
'href' => $this->href,
|
'href' => $this->href,
|
||||||
'class' => 'phui-object-item-link',
|
'class' => 'phui-object-item-link',
|
||||||
'title' => ($this->href) ? $this->header : null,
|
'title' => $title_text,
|
||||||
),
|
),
|
||||||
$this->header);
|
$this->header);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue