Bug 288223
Summary: | RegExp with /v incorrectly handles literal hyphen as creating an invalid range | ||
---|---|---|---|
Product: | WebKit | Reporter: | Steven Levithan <steves_list> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | karlcow, mark.lam, msaboff, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | PC | ||
OS: | Windows 11 |
Steven Levithan
WebKit is throwing a SyntaxError for regexes when all of the following conditions are met:
- The regex uses flag `v`.
- The regex contains a character class with the following:
- Any character set (ex: `\d` or `\p{L}`).
- Immediately followed by any representation of a literal hyphen, such as `\-`, `\x2D`, or `\u002D`.
- Followed by another token.
When this occurs, WebKit treats the literal hyphen as if it was creating a range. So e.g. the perfectly valid regex `/[\d\-a]/v` is handled as if it were the invalid `/[\d-a]/v` and throws "SyntaxError: Invalid regular expression: invalid range in character class for Unicode pattern".
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Steven Levithan
Example of this bug in the wild: https://github.com/shikijs/shiki/issues/927
Radar WebKit Bug Importer
<rdar://problem/145874688>
Sosuke Suzuki
Pull request: https://github.com/WebKit/WebKit/pull/41732
EWS
Committed 291709@main (7adb2e46f423): <https://commits.webkit.org/291709@main>
Reviewed commits have been landed. Closing PR #41732 and removing active labels.