[Webkit-unassigned] [Bug 214181] New: RegExp sticky not matching alternates correctly, ignoring lastIndex requirement

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jul 10 04:52:42 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=214181

            Bug ID: 214181
           Summary: RegExp sticky not matching alternates correctly,
                    ignoring lastIndex requirement
           Product: WebKit
           Version: Safari 13
          Hardware: Macintosh
                OS: macOS 10.15
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: eoind at vey.ie

Created attachment 403958

  --> https://bugs.webkit.org/attachment.cgi?id=403958&action=review

Screenshot of Safari console

Regular expressions sticky flag is not working correctly when used with alternates (|)

Demonstration: (In Safari 13 JS console)

Entering `/a|aa/y.exec("_a")` returns `["a"]` when it should return `null`. This is because matches should be restricted to starting at lastIndex which in this case is index 0.

Chrome, Firefox and Edge all correctly return `null`

Further proof that this is a bug can be seen as follows. Obviously /a|aa/ should be exactly the same as /(a|aa)/ as capturing groups are not relevant. But entering `/(a|aa)/y.exec("_a")` returns `null`.

Similarly wrapping the rhs of the alternate expression shouldn't affect the result but `/a|(aa)/y.exec("_a")` also correctly returns `null`.

This bug seems related to this bug from 2010: https://bugs.webkit.org/show_bug.cgi?id=48102

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200710/edb20220/attachment.htm>


More information about the webkit-unassigned mailing list