Homec4science

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

Authored by epriestley <git@epriestley.com> on Aug 26 2015, 18:35.

Description

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

Details

Committed
epriestley <git@epriestley.com>Aug 26 2015, 18:35
Pushed
aubortJan 31 2017, 17:16
Parents
rPH779a612e4172: Fix mail parameter error with old migrations
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPH10966519e2eb: Prevent "commit message magic words" parser from exploding on "reverts aaaa..... (authored by epriestley <git@epriestley.com>).Aug 26 2015, 18:35