search:handle ^ as first character in character class
Created by: stefanhengl
Relates to #12476
Previously we did not handle ^
within character classes so that [^-b]
(glob) was translated to ^[^-b]$
(regex) which is not the same.
Additionally, we handled -
very strictly, following the UNIX man page for glob. However, we can be much more forgiving because google re2 can handle even those cases we previously excluded, like [a-b-c]
or [a-z--0]
.
Because of the code change, a switch block in translateCharacterClass
became obsolete and I removed it, which unfortunately bloats the diff. However, I didn't change the tests apart from adding new ones and moving [a-b-c]
or [a-z--0]
from "not allowed" to "allowed".
Note: I fuzzed the parser without any crashers.