Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15626128
D7974.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7974.diff
View Options
Index: src/markup/engine/__tests__/remarkup/link-brackets.txt
===================================================================
--- src/markup/engine/__tests__/remarkup/link-brackets.txt
+++ src/markup/engine/__tests__/remarkup/link-brackets.txt
@@ -1,5 +1,5 @@
-<http://www.zany.com/omg/space url/>
+<http://www.zany.com/omg/weird_url,,,>
~~~~~~~~~~
-<p><a href="http://www.zany.com/omg/space url/" target="_blank">http://www.zany.com/omg/space url/</a></p>
+<p><a href="http://www.zany.com/omg/weird_url,,," target="_blank">http://www.zany.com/omg/weird_url,,,</a></p>
~~~~~~~~~~
-http://www.zany.com/omg/space url/
+http://www.zany.com/omg/weird_url,,,
Index: src/markup/engine/__tests__/remarkup/link-mixed.txt
===================================================================
--- /dev/null
+++ src/markup/engine/__tests__/remarkup/link-mixed.txt
@@ -0,0 +1,18 @@
+[[http://www.example.com/ | Example]](http://www.alternate.org/)
+
+(http://www.alternate.org/)[[http://www.example.com/ | Example]]
+
+<http://www.example.com/ [[http://www.example.net/ | Example]]>
+
+~~~~~~~~~~
+<p><a href="http://www.example.com/" target="_blank">Example</a>(<a href="http://www.alternate.org/" target="_blank">http://www.alternate.org/</a>)</p>
+
+<p>(<a href="http://www.alternate.org/" target="_blank">http://www.alternate.org/</a>)<a href="http://www.example.com/" target="_blank">Example</a></p>
+
+<p><<a href="http://www.example.com/" target="_blank">http://www.example.com/</a> <a href="http://www.example.net/" target="_blank">Example</a>></p>
+~~~~~~~~~~
+Example <http://www.example.com/>(http://www.alternate.org/)
+
+(http://www.alternate.org/)Example <http://www.example.com/>
+
+<http://www.example.com/ Example <http://www.example.net/>>
Index: src/markup/engine/remarkup/PhutilRemarkupBlockStorage.php
===================================================================
--- src/markup/engine/remarkup/PhutilRemarkupBlockStorage.php
+++ src/markup/engine/remarkup/PhutilRemarkupBlockStorage.php
@@ -34,11 +34,13 @@
*/
final class PhutilRemarkupBlockStorage {
+ const MAGIC_BYTE = "\1";
+
private $map = array();
private $index;
public function store($text) {
- $key = "\1".(++$this->index)."Z";
+ $key = self::MAGIC_BYTE.(++$this->index)."Z";
$this->map[$key] = $text;
return $key;
}
Index: src/markup/engine/remarkup/markuprule/PhutilRemarkupRuleHyperlink.php
===================================================================
--- src/markup/engine/remarkup/markuprule/PhutilRemarkupRuleHyperlink.php
+++ src/markup/engine/remarkup/markuprule/PhutilRemarkupRuleHyperlink.php
@@ -18,7 +18,7 @@
// with weird characters". This is assumed to be reasonable because they
// don't appear in normal text or normal URLs.
$text = preg_replace_callback(
- '@<(\w{3,}://.+?)>@',
+ '@<(\w{3,}://[^\s'.PhutilRemarkupBlockStorage::MAGIC_BYTE.']+?)>@',
array($this, 'markupHyperlink'),
$text);
@@ -26,8 +26,11 @@
// stuff that's probably puncutation or otherwise not part of the URL and
// not link it. This lets someone write "QuicK! Go to
// http://www.example.com/!". We also apply some paren balancing rules.
+
+ // NOTE: We're explicitly avoiding capturing stored blocks, so text like
+ // `http://www.example.com/[[x | y]]` doesn't get aggressively captured.
$text = preg_replace_callback(
- '@(\w{3,}://\S+)@',
+ '@(\w{3,}://[^\s'.PhutilRemarkupBlockStorage::MAGIC_BYTE.']+)@',
array($this, 'markupHyperlinkUngreedy'),
$text);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, May 19, 2:14 PM (4 h, 40 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8005421
Default Alt Text
D7974.diff (3 KB)
Attached To
Mode
D7974: Fix excessively aggressive capturing of hyperlinks in Remarkup
Attached
Detach File
Event Timeline
Log In to Comment