@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.

Rewrite regex for project names to be not prone to catastrophic backtracking

Summary: Fixes T15371

Test Plan:
- Save the text `{{#translation:}}` in remarkup and see that it renders.
- Create a project or projects with the hashtags `a`, `b`, `ab`, `foo`, `f.o.o`.
- Observe that both before and after this patch you can link to all of them by hashtag.
- Create a project or projects with the hashtags `a.`, `.b`, `.foo`, `foo.`.
- Observe that both before and after this patch you can link to none of them by hashtag.

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15371

Differential Revision: https://we.phorge.it/D25838

Pppery 9c73d62c 48fd3f1c

+10 -8
+10 -8
src/applications/project/remarkup/ProjectRemarkupRule.php
··· 22 22 } 23 23 24 24 protected function getObjectIDPattern() { 25 - // NOTE: The latter half of this rule matches monograms with internal 26 - // periods, like `#domain.com`, but does not match monograms with terminal 25 + // NOTE: This rule matches monograms with internal periods, 26 + // like `#domain.com`, but does not match monograms with terminal 27 27 // periods, because they're probably just punctuation. 28 28 29 29 // Broadly, this will not match every possible project monogram, and we ··· 39 39 // These characters may not appear at the edge of the string. 40 40 $never_edge = '.'; 41 41 42 - return 43 - '[^'.$never_edge.$never.']+'. 44 - '(?:'. 45 - '[^'.$never.']*'. 46 - '[^'.$never_edge.$never.']+'. 47 - ')*'; 42 + return '(?:'. 43 + // Short project name with one or two characters not in $never_edge or 44 + '[^'.$never_edge.$never.']{1,2}|'. 45 + // A single character not in $never or $never_edge, 46 + // then any number of characters not in $never then a single character 47 + // not in $never or $never_edge 48 + '[^'.$never_edge.$never.'][^'.$never.']+[^'.$never_edge.$never.']'. 49 + ')'; 48 50 } 49 51 50 52 protected function loadObjects(array $ids) {