1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 20:40:56 +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:
epriestley 2015-05-04 18:34:40 -07:00
parent f311f3f910
commit c5a734073d
2 changed files with 24 additions and 4 deletions

View file

@ -31,12 +31,12 @@ final class PhabricatorSearchResultView extends AphrontView {
$type_name = nonempty($handle->getTypeName(), pht('Document'));
$title = $this->emboldenQuery($handle->getFullName());
if ($handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
}
$raw_title = $handle->getFullName();
$title = $this->emboldenQuery($raw_title);
$item = id(new PHUIObjectItemView())
->setHeader($title)
->setTitleText($raw_title)
->setHref($handle->getURI())
->setImageURI($handle->getImageURI())
->addAttribute($type_name);
@ -110,6 +110,9 @@ final class PhabricatorSearchResultView extends AphrontView {
$buf = '';
$pos = 0;
$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) {
if ($bold[$pos] != $is_bold) {
if (strlen($buf)) {

View file

@ -22,6 +22,7 @@ final class PHUIObjectItemView extends AphrontTagView {
private $state;
private $fontIcon;
private $imageIcon;
private $titleText;
const AGE_FRESH = 'fresh';
const AGE_STALE = 'stale';
@ -98,6 +99,15 @@ final class PHUIObjectItemView extends AphrontTagView {
return $this;
}
public function setTitleText($title_text) {
$this->titleText = $title_text;
return $this;
}
public function getTitleText() {
return $this->titleText;
}
public function getHeader() {
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(
$this->href ? 'a' : 'div',
array(
'href' => $this->href,
'class' => 'phui-object-item-link',
'title' => ($this->href) ? $this->header : null,
'title' => $title_text,
),
$this->header);