mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Support possessive quantifiers, which cannot backtrack.
They are approximated by limiting them to up to one repetition (effectively making *+ like ? and ++ like a no-op).
This commit is contained in:
@@ -418,6 +418,17 @@ class ExpRedosTest {
|
||||
"\\A(\\d|0)*x", // $ hasExpRedos
|
||||
"(\\d|0)*\\Z", // $ hasExpRedos
|
||||
"\\b(\\d|0)*x", // $ hasExpRedos
|
||||
|
||||
// GOOD - possessive quantifiers don't backtrack
|
||||
"(a*+)*+b",
|
||||
"(a*)*+b",
|
||||
"(a*+)*b",
|
||||
|
||||
// BAD
|
||||
"(a*)*b", // $ hasExpRedos
|
||||
|
||||
// BAD - but not detected due to the way possessive quantifiers are approximated
|
||||
"((aa|a*+)b)*c" // $ MISSING: hasExpRedos
|
||||
};
|
||||
|
||||
void test() {
|
||||
|
||||
Reference in New Issue
Block a user