Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2690169
D25157.1734746299.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
D25157.1734746299.diff
View Options
diff --git a/src/view/phui/PHUIObjectItemView.php b/src/view/phui/PHUIObjectItemView.php
--- a/src/view/phui/PHUIObjectItemView.php
+++ b/src/view/phui/PHUIObjectItemView.php
@@ -83,11 +83,33 @@
return $this->object;
}
+ /**
+ * Set the href attribute
+ *
+ * @param string|PhutilURI|null $href
+ * @return self
+ */
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 stuff!
+ // https://we.phorge.it/T15316
+ try {
+ self::assertValidHref($href, 'href');
+ } catch (Exception $ex) {
+ phlog($ex);
+ }
+
$this->href = $href;
return $this;
}
+ /**
+ * Get the href attribute
+ *
+ * @see PHUIObjectItemView::setHref()
+ * @return string|PhutilURI|null
+ */
public function getHref() {
return $this->href;
}
@@ -136,7 +158,23 @@
return $this;
}
+ /**
+ * Set the image href attribute
+ *
+ * @param string|PhutilURI|null $image_href
+ * @return self
+ */
public function setImageHref($image_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 stuff!
+ // https://we.phorge.it/T15316
+ try {
+ self::assertValidHref($image_href, 'image_href');
+ } catch (Exception $ex) {
+ phlog($ex);
+ }
+
$this->imageHref = $image_href;
return $this;
}
@@ -659,8 +697,8 @@
$this->getImageIcon());
}
- if ($image && (phutil_nonempty_string($this->href) ||
- phutil_nonempty_string($this->imageHref))) {
+ if ($image && (phutil_nonempty_stringlike($this->href) ||
+ phutil_nonempty_stringlike($this->imageHref))) {
$image_href = ($this->imageHref) ? $this->imageHref : $this->href;
$image = phutil_tag(
'a',
@@ -899,4 +937,30 @@
return javelin_tag('span', $options, '');
}
+
+ /**
+ * Receive a href attribute and check if it has expected values
+ *
+ * TODO: Feel free to remove after 2023, if no more new reports arrive.
+ *
+ * https://we.phorge.it/T15316
+ *
+ * @param mixed $href
+ * @param string $variable_name
+ */
+ private static function assertValidHref($href, $variable_name) {
+
+ // We have not a very clear idea about what this method should receive
+ // We suspect that PhutilURI should be allowed... but let's log stuff!
+ if (is_object($href) && !($href instanceof PhutilURI)) {
+
+ throw new Exception(pht(
+ 'The variable %s received an unexpected type: %s. '.
+ 'Please share this stack trace as comment in Task %s',
+ $variable_name,
+ get_class($href),
+ 'https://we.phorge.it/T15316'));
+ }
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 01:58 (17 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1021609
Default Alt Text
D25157.1734746299.diff (2 KB)
Attached To
Mode
D25157: Fix regression in PHUIObjectItemView.php:662: allow PhutilURI and other stringlike
Attached
Detach File
Event Timeline
Log In to Comment