Page MenuHomePhabricator

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

Authored by epriestley on Aug 26 2015, 4:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 29, 4:18 PM
Unknown Object (File)
Mon, Apr 29, 4:06 PM
Unknown Object (File)
Wed, Apr 24, 11:54 PM
Unknown Object (File)
Fri, Apr 12, 8:44 AM
Unknown Object (File)
Fri, Apr 12, 8:43 AM
Unknown Object (File)
Fri, Apr 12, 8:27 AM
Unknown Object (File)
Fri, Apr 12, 7:18 AM
Unknown Object (File)
Thu, Apr 11, 8:10 AM
Subscribers
None

Details

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.

Diff Detail

Repository
rP Phabricator
Branch
monoparser
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 7817
Build 8666: [Placeholder Plan] Wait for 30 Seconds
Build 8665: arc lint + arc unit

Event Timeline

epriestley retitled this revision from to Prevent "commit message magic words" parser from exploding on "reverts aaaa.....aaz".
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.Aug 26 2015, 4:30 PM
This revision was automatically updated to reflect the committed changes.