Bug 210576

Summary: Certain regexes with range-quantified groups fail to match
Product: WebKit Reporter: Ross Kirsling <ross.kirsling>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ashvayka, hi, msaboff
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=188407

Ross Kirsling
Reported 2020-04-15 15:58:10 PDT
I'm not even sure what to title this, but I extracted it from test262/harness/testIntl.js. The following is false for JSC but true for all other engines: ``` /(?:\w+-)+((\w){5,8})-\1/.test('de-gregory-gregory') ``` This was as far as I could manage to shrink the regex. (The backreference can be inlined and the nested group can be made a non-capturing group, but everything else seems needed?)
Attachments
Devin Rousso
Comment 1 2020-04-15 16:04:01 PDT
This works tho 🤔 ``` /(?:\w+-)+(\w{5,8})-\1/.test('de-gregory-gregory') ```
Ross Kirsling
Comment 2 2020-04-15 16:05:14 PDT Comment hidden (obsolete)
Alexey Shvayka
Comment 3 2020-04-15 16:06:36 PDT
(In reply to Ross Kirsling from comment #0) > The following is false for JSC but true for all other engines: Same result in Safari 12.1. I wonder if it's the same issue as in https://bugs.webkit.org/show_bug.cgi?id=188407?
Devin Rousso
Comment 4 2020-04-15 16:07:52 PDT Comment hidden (obsolete)
Ross Kirsling
Comment 5 2020-04-19 16:42:16 PDT
Alexey noticed that my shrunken regex in comment 0 succeeds with a `u` flag, but the original regex does not. If we unshrink just a bit, this fails: /(?:\w+-)+((\w){5,8})-((\w){5,8}-)*\1/u.test('de-gregory-gregory') ...which may suggest multiple issues at play. I also kept trying ways to further shrink/restrict the comment 0 regex and noticed that the following fails (with or without `u`): /^(?:aa~)+(?:a){2,3}~aa?a?a?$/.test('aa~aa~aaaa') ...so nested groups may not be necessary, but that (?:a){2,3} is really important. It needs to be a quantified group with a lower bound greater than 1 and an upper bound greater than the lower bound. (Presumably the bound restrictions are needed so that it doesn't get automatically simplified?)
Note You need to log in before you can comment on or make changes to this bug.