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

Prevent "commit message magic words" parser from exploding on "reverts aaaa.....aaz"

Summary:
Fixes T9268. Currently, we try to match any string like "a2f313f1" as a commit/revision, so short hashes will get picked up.

However, we don't require a word boundary or terminal after the match, so for input like "aaa...aaaaz" the engine can get stuck trying to split the string into sub-matches.

That is, in the original case, the input "aaaz" had valid matches against `[rA-Z0-9a-f]+` up to "z" of:

aaa
aa a
a aa
a a a

All of these will fail once it hits "z", but it has to try them all. This complexity is explosive with longer strings.

Instead, require a word boundary or EOL after the match, so this is the only valid match:

aaa

Then the engine sees the "z", says "nope, no match" and doesn't have to backtrack across all possible combinations.

Test Plan: Added a failing unit test, applied patch, clean test.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9268

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

+5 -2
+3
src/applications/differential/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php
··· 76 76 ), 77 77 ), 78 78 79 + // This tests a degenerate regex behavior, see T9268. 80 + 'Reverts aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz' => array(), 81 + 79 82 "This doesn't revert anything" => array(), 80 83 'nonrevert of r11' => array(), 81 84 'fixed a bug' => array(),
+2 -2
src/infrastructure/customfield/parser/PhabricatorCustomFieldMonogramParser.php
··· 24 24 '(?:^|\b)'. 25 25 $prefix_regex. 26 26 $infix_regex. 27 - '((?:'.$monogram_pattern.'[,\s]*)+)'. 28 - '(?:\band\s+('.$monogram_pattern.'))?'. 27 + '((?:'.$monogram_pattern.'(?:\b|$)[,\s]*)+)'. 28 + '(?:\band\s+('.$monogram_pattern.'(?:\b|$)))?'. 29 29 $suffix_regex. 30 30 '(?:$|\b)'. 31 31 '/';