Do not validate a backreference if the group that it refers to is not valid

implementBackreferences
Aadhavan Srinivasan 4 weeks ago
parent 2934e7a20f
commit 81b8b1b11c

@ -319,7 +319,7 @@ func findAllSubmatchHelper(start *nfaState, str []rune, offset int, numGroups in
if currentState.contentContains(str, idx, preferLongest) {
nextStates = addStateToList(str, idx+1, nextStates, *currentState.next, currentState.threadGroups, nil, preferLongest)
}
} else if currentState.isBackreference {
} else if currentState.isBackreference && currentState.threadGroups[currentState.referredGroup].IsValid() {
groupLength := currentState.threadGroups[currentState.referredGroup].EndIdx - currentState.threadGroups[currentState.referredGroup].StartIdx
if currentState.threadBackref == groupLength {
currentState.threadBackref = 0

Loading…
Cancel
Save