fuzz: compiling '\P{any}' panics by tripping an assertion in the compiler #722
Labels
Comments
This was referenced Mar 12, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Specifically, this one:
regex/src/compile.rs
Line 419 in a7ef5f4
Normally, regexes like
[^\w\W]
with empty classes are banned at translation time. But it looks like\P{any}
(which is empty) slipped through. So we should just improve the ban to cover that case.However, empty character classes are occasionally useful constructs for injecting a "fail" sub-pattern into a regex, typically in the context of cases where regexes are generated. Indeed, the NFA compiler in
regex-automata
handles this case fine:Where it's impossible to ever move past state
2
. Arguably, it might be nicer if it were an explicit "fail" instruction, but an empty sparse instruction (a state with no outgoing transitions) serves the purpose as well.So once #656 is done, we should be able to relax this restriction.
This bug was found by OSS-Fuzz.
The text was updated successfully, but these errors were encountered: