@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a negative lookbehind to the Remarkup "bare URI" regular expression pattern

Summary: Ref T13608. Building on D21562, further anchor this pattern by adding a negative lookbehind.

Test Plan: Ran unit tests.

Maniphest Tasks: T13608

Differential Revision: https://secure.phabricator.com/D21568

+8 -5
+8 -5
src/infrastructure/markup/markuprule/PhutilRemarkupHyperlinkRule.php
··· 14 14 static $bare_pattern; 15 15 16 16 if ($angle_pattern === null) { 17 - // See T13608. Limit protocol matches to 32 characters to improve the 18 - // performance of the "<protocol>://" pattern, which can take a very long 19 - // time to match against long inputs if the maximum length of a protocol 20 - // sequence is unrestricted. 17 + // See T13608. A previous version of this code matched bare URIs 18 + // starting with "\w{3,}", which can take a very long time to match 19 + // against long inputs. 20 + // 21 + // Use a protocol length limit in all patterns for general sanity, 22 + // and a negative lookbehind in the bare pattern to avoid explosive 23 + // complexity during expression evaluation. 21 24 22 25 $protocol_fragment = '\w{3,32}'; 23 26 $uri_fragment = '[^\s'.PhutilRemarkupBlockStorage::MAGIC_BYTE.']+'; ··· 33 36 $uri_fragment); 34 37 35 38 $bare_pattern = sprintf( 36 - '(%s://%s)', 39 + '((?<!\w)%s://%s)', 37 40 $protocol_fragment, 38 41 $uri_fragment); 39 42 }