[Webkit-unassigned] [Bug 157723] New: RegExp /y flag incorrect handling of mixed-length alternation

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun May 15 02:16:15 PDT 2016


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

            Bug ID: 157723
           Summary: RegExp /y flag incorrect handling of mixed-length
                    alternation
    Classification: Unclassified
           Product: WebKit
           Version: Safari Technology Preview
          Hardware: Unspecified
                OS: OS X 10.11
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: steves_list at hotmail.com

This issue broke the XRegExp library. I've added a workaround in XRegExp 3.1.1 -- see <https://github.com/slevithan/xregexp/issues/135>.

Safari Technology Preview v9.1.1 has a bug in its handling of the ES 2015 RegExp /y flag. Here is some test output, with the last example showing the bug:

```
/a|b/y.test('a'); // -> true
/a|b/y.test('b'); // -> true
/b|a/y.test('a'); // -> true
/b|a/y.test('b'); // -> true
/aa|bb/y.test('aa'); // -> true
/aa|bb/y.test('bb'); // -> true
/bb|aa/y.test('aa'); // -> true
/bb|aa/y.test('bb'); // -> true
/a|bb/y.test('a'); // -> true
/a|bb/y.test('bb'); // -> true
/bb|a/y.test('bb'); // -> true
/bb|a/y.test('a'); // -> false [should be true]
```

It seems that if a regex with flag y evaluates a path within a regex with more than 1 character, it advances its internal lastIndex that the y flag is anchored to, and does not reset this position when the alternative fails and another path in the regex with fewer characters to match is tried. Or something along those lines.

Safari 9.1 does not have this issue, since 9.1.1 is the first version to support /y. Also, no other current browser that supports /y (Edge, Firefox, Chrome, Opera) has this bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160515/539b0875/attachment.html>


More information about the webkit-unassigned mailing list