revert marking repetitions with possibly empty body as forks

This commit is contained in:
Erik Krogh Kristensen
2020-12-03 20:08:07 +01:00
parent 33b2701551
commit cc98c41dd6
3 changed files with 9 additions and 43 deletions

View File

@@ -702,28 +702,6 @@ predicate isFork(State q, InputSymbol s1, InputSymbol s2, State r1, State r2) {
r1 != r2
or
r1 = r2 and q1 != q2
or
r1 = r2 and
q1 = q2 and
epsilonSucc+(q) = q and
exists(RegExpTerm term | term = q.getRepr() | term instanceof InfiniteRepetitionQuantifier) and
(
// There is either multiple possible "mid" states.
count(State mid |
mid = epsilonSucc+(q) and
q = epsilonSucc+(mid) and
not mid = q
) > 2
or
// Or one of the mid states is an infinite quantifier itself
exists(State mid, RegExpTerm term |
mid = epsilonSucc+(q) and
q = epsilonSucc+(mid) and
not mid = q and
term = mid.getRepr() and
term instanceof InfiniteRepetitionQuantifier
)
)
) and
stateInsideBacktracking(r1) and
stateInsideBacktracking(r2)
@@ -1164,8 +1142,7 @@ predicate isReDoSCandidate(State state, string pump) {
bindingset[s]
string escape(string s) {
result =
s
.replaceAll("\\", "\\\\")
s.replaceAll("\\", "\\\\")
.replaceAll("\n", "\\n")
.replaceAll("\r", "\\r")
.replaceAll("\t", "\\t")