Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUITagView.php
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | public function setPHID($phid) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setName($name) { | public function setName($name) { | ||||
$this->name = $name; | $this->name = $name; | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* Set the href attribute | |||||
* | |||||
* @param string|null $href | |||||
* @return self | |||||
*/ | |||||
public function setHref($href) { | public function setHref($href) { | ||||
// We have not a very clear idea about what this method should receive | |||||
// We suspect that PhutilURI should be allowed... but let's log everything! | |||||
// https://we.phorge.it/T15316 | |||||
if (is_object($href)) { | |||||
phlog(sprintf( | |||||
'Received unexpected type for href: %s. '. | |||||
'Please paste this log as comment in https://we.phorge.it/T15316', | |||||
get_class($href))); | |||||
} | |||||
$this->href = $href; | $this->href = $href; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setClosed($closed) { | public function setClosed($closed) { | ||||
$this->closed = $closed; | $this->closed = $closed; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setBorder($border) { | public function setBorder($border) { | ||||
$this->border = $border; | $this->border = $border; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setIcon($icon) { | public function setIcon($icon) { | ||||
$this->icon = $icon; | $this->icon = $icon; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setSlimShady($is_eminem) { | public function setSlimShady($is_eminem) { | ||||
valerio.bozzolan: AHAHAHAHAHAHAHAH WHAT THE F**** | |||||
$this->slimShady = $is_eminem; | $this->slimShady = $is_eminem; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function getTagName() { | protected function getTagName() { | ||||
return strlen($this->href) ? 'a' : 'span'; | return phutil_nonempty_stringlike($this->href) ? 'a' : 'span'; | ||||
Done Inline Actions✅ I tested this in 100+ pages without finding any explosion related to non-null or non-string. I think it's good if phutil_nonempty_string() will report any alien value. In case, we will pass to phutil_nonempty_stringlike(). valerio.bozzolan: ✅ I tested this in 100+ pages without finding any explosion related to non-null or non-string. | |||||
} | } | ||||
public function setContextObject($context_object) { | public function setContextObject($context_object) { | ||||
$this->contextObject = $context_object; | $this->contextObject = $context_object; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getContextObject() { | public function getContextObject() { | ||||
Show All 37 Lines | if ($this->border) { | ||||
$classes[] = 'phui-tag-'.$this->border; | $classes[] = 'phui-tag-'.$this->border; | ||||
} | } | ||||
if ($this->getIsExiled()) { | if ($this->getIsExiled()) { | ||||
$classes[] = 'phui-tag-exiled'; | $classes[] = 'phui-tag-exiled'; | ||||
} | } | ||||
$attributes = array( | $attributes = array( | ||||
'href' => $this->href, | 'href' => $this->href, | ||||
Not Done Inline ActionsThe value of href is passed as-is, and, the frontend just casts it to a string as expected: function phutil_tag($tag, array $attributes = array(), $content = null) { // If the `href` attribute is present, make sure it is not a "javascript:" // URI. We never permit these. if (!empty($attributes['href'])) { // This might be a URI object, so cast it to a string. $href = (string)$attributes['href']; // ← ← ← ← ← ← if (isset($href[0])) { // (weird check) to check if the string it's not empty So, whenever you have a string, or something that can be converted to a string, that value is OK. valerio.bozzolan: The value of `href` is passed as-is, and, the frontend just casts it to a string as expected… | |||||
'class' => $classes, | 'class' => $classes, | ||||
); | ); | ||||
if ($this->external) { | if ($this->external) { | ||||
$attributes += array( | $attributes += array( | ||||
'target' => '_blank', | 'target' => '_blank', | ||||
'rel' => 'noreferrer', | 'rel' => 'noreferrer', | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
AHAHAHAHAHAHAHAH WHAT THE F****