Page MenuHomePhorge

D25082.1737654644.diff
No OneTemporary

D25082.1737654644.diff

diff --git a/src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php b/src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php
--- a/src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php
+++ b/src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php
@@ -45,11 +45,11 @@
$engine = $this->getEngine();
$is_anchor = false;
- if (strncmp($link, '/', 1) == 0) {
+ if ($this->isURIRelativePath($link)) {
$base = phutil_string_cast($engine->getConfig('uri.base'));
$base = rtrim($base, '/');
$link = $base.$link;
- } else if (strncmp($link, '#', 1) == 0) {
+ } else if ($this->isURIAnchor($link)) {
$here = $engine->getConfig('uri.here');
$link = $here.$link;
diff --git a/src/infrastructure/markup/markuprule/PhutilRemarkupRule.php b/src/infrastructure/markup/markuprule/PhutilRemarkupRule.php
--- a/src/infrastructure/markup/markuprule/PhutilRemarkupRule.php
+++ b/src/infrastructure/markup/markuprule/PhutilRemarkupRule.php
@@ -106,4 +106,28 @@
return (strpos($text, PhutilRemarkupBlockStorage::MAGIC_BYTE) === false);
}
+ /**
+ * Check whenever an URI is an anchor
+ *
+ * @param string $uri
+ * @return bool
+ */
+ protected function isURIAnchor($uri) {
+ return strncmp($uri, '#', 1) == 0;
+ }
+
+ /**
+ * Is this URI a relative pathname
+ *
+ * @param string $uri Example '/path' etc.
+ * @return string
+ */
+ protected function isURIRelativePath($uri) {
+ // NOTE: This was the original check, but at
+ // the moment '/' is assumed as relative but
+ // './' is assumed as not relative, and this
+ // may be confusing and may deserve a future update
+ return strncmp($uri, '/', 1) == 0;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 23, 17:50 (2 w, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1146083
Default Alt Text
D25082.1737654644.diff (1 KB)

Event Timeline