Bug 260928
Summary: | [Yarr] Yarr JIT returns a nested capture when an outer paren matches a zero length string | ||
---|---|---|---|
Product: | WebKit | Reporter: | Michael Saboff <msaboff> |
Component: | JavaScriptCore | Assignee: | Michael Saboff <msaboff> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Michael Saboff
Consider the RegExp /(?:(?=(abc)))?a/. The lookahead assertion contains a captured sub pattern of "abc". The outer group is quantified with the '?' suffix, which means it can match 0 or 1 times. When this RegExp is used to match the string "abc", the assertion will match the "abc" and that sub pattern will be captured. The ECMAScript spec in [RepeastMatcher](https://tc39.es/ecma262/#sec-runtime-semantics-repeatmatcher-abstract-operation) for the case where the minimum match quantity is 0. See step 2.b. in the spec link.
The Yarr interpreter matches as the spec requires, returning the capture only if the quantifier has a minimum of 1. The Yarr JIT however always returns the nested capture, irrespective of the quantifier for the outer paren. Therefore the JIT needs to be fix to match the spec and the interpreter.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Michael Saboff
<rdar://106376813>
Michael Saboff
Pull request: https://github.com/WebKit/WebKit/pull/17254
EWS
Committed 267486@main (e5b0472ba9a2): <https://commits.webkit.org/267486@main>
Reviewed commits have been landed. Closing PR #17254 and removing active labels.