Page MenuHomePhabricator

D18666.diff
No OneTemporary

D18666.diff

diff --git a/src/markup/engine/__tests__/remarkup/link-with-angle-link-anchor.txt b/src/markup/engine/__tests__/remarkup/link-with-angle-link-anchor.txt
new file mode 100644
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/link-with-angle-link-anchor.txt
@@ -0,0 +1,5 @@
+<http://x.y#http://x.y#>
+~~~~~~~~~~
+<p>&lt;http://x.y#http://x.y#&gt;</p>
+~~~~~~~~~~
+<http://x.y#http://x.y#>
diff --git a/src/markup/engine/__tests__/remarkup/link-with-link-anchor.txt b/src/markup/engine/__tests__/remarkup/link-with-link-anchor.txt
new file mode 100644
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/link-with-link-anchor.txt
@@ -0,0 +1,5 @@
+http://x.y#http://x.y#
+~~~~~~~~~~
+<p>http://x.y#http://x.y#</p>
+~~~~~~~~~~
+http://x.y#http://x.y#
diff --git a/src/markup/engine/remarkup/markuprule/PhutilRemarkupHyperlinkRule.php b/src/markup/engine/remarkup/markuprule/PhutilRemarkupHyperlinkRule.php
--- a/src/markup/engine/remarkup/markuprule/PhutilRemarkupHyperlinkRule.php
+++ b/src/markup/engine/remarkup/markuprule/PhutilRemarkupHyperlinkRule.php
@@ -32,11 +32,18 @@
}
protected function markupHyperlink(array $matches) {
+ try {
+ $uri = new PhutilURI($matches[1]);
+ } catch (Exception $ex) {
+ return $matches[0];
+ }
+
+ $protocol = $uri->getProtocol();
+
$protocols = $this->getEngine()->getConfig(
'uri.allowed-protocols',
array());
- $protocol = id(new PhutilURI($matches[1]))->getProtocol();
if (!idx($protocols, $protocol)) {
// If this URI doesn't use a whitelisted protocol, don't link it. This
// is primarily intended to prevent javascript:// silliness.
@@ -102,6 +109,12 @@
$match = substr($match, 0, -1);
}
+ try {
+ $uri = new PhutilURI($match);
+ } catch (Exception $ex) {
+ return $matches[0];
+ }
+
return hsprintf('%s%s', $this->markupHyperlink(array(null, $match)), $tail);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 19, 6:42 AM (4 d, 6 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7221680
Default Alt Text
D18666.diff (1 KB)

Event Timeline