Bug 249146

Summary: Regular expression fails in WebKit only: invalid group specifier name
Product: WebKit Reporter: Vladimir Prelovac <vprelovac>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: karlcow, mark.lam, msaboff, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   

Description Vladimir Prelovac 2022-12-12 07:09:49 PST
The following regular expression works in Chrome and Firefox,  but fails in WebKit:

let tokens = "test".match(/(?<=\s+|^)["'‘“'"[({⟨]?(.*?[.?!])(\s[.?!])*["'’”'"\])}⟩]?(?=\s+|$)|(?<=\s+|^)\S(.*?[.?!])(\s[.?!])*(?=\s+|$)/g);

SyntaxError: Invalid regular expression: invalid group specifier name
Comment 1 Radar WebKit Bug Importer 2022-12-16 15:02:31 PST
<rdar://problem/103461779>
Comment 2 Michael Saboff 2022-12-16 15:30:28 PST
This was fixed with commit 257823@main (46e6b3f97425): <https://commits.webkit.org/257823@main>.

*** This bug has been marked as a duplicate of bug 174931 ***
Comment 3 Vladimir Prelovac 2022-12-16 18:48:57 PST
(In reply to Michael Saboff from comment #2)
> This was fixed with commit 257823@main (46e6b3f97425):
> <https://commits.webkit.org/257823@main>.
> 
> *** This bug has been marked as a duplicate of bug 174931 ***

I've compiled trunk with the patch in and want to report that this problem is still not fixed.
Comment 4 Mark Lam 2022-12-16 18:54:27 PST
(In reply to Vladimir Prelovac from comment #3)
> > *** This bug has been marked as a duplicate of bug 174931 ***
> 
> I've compiled trunk with the patch in and want to report that this problem
> is still not fixed.

Are you sure you're building the latest trunk?  I just tried against trunk also, and I also no longer see that SyntaxError.  Looks fixed to me.
Comment 5 Vladimir Prelovac 2022-12-16 18:59:06 PST
(In reply to Mark Lam from comment #4)
> (In reply to Vladimir Prelovac from comment #3)
> > > *** This bug has been marked as a duplicate of bug 174931 ***
> > 
> > I've compiled trunk with the patch in and want to report that this problem
> > is still not fixed.
> 
> Are you sure you're building the latest trunk?  I just tried against trunk
> also, and I also no longer see that SyntaxError.  Looks fixed to me.

Thanks for double checking. I did indeed pull the trunk an hour ago and verified it is latest trunk by verifying the patch was applied. (for example Source/JavaScriptCore/runtime/RegExp.cpp line 252 is " && !pattern.m_containsLookbehinds") The Webkit version also shows as 615.1.15+

Then I went to https://runjs.co (since don't have inspector in minibrowser/run-safari) and ran:

let tokens = "test".match(/(?<=\s+|^)["'‘“'"[({⟨]?(.*?[.?!])(\s[.?!])*["'’”'"\])}⟩]?(?=\s+|$)|(?<=\s+|^)\S(.*?[.?!])(\s[.?!])*(?=\s+|$)/g);

Producing:
SyntaxError: Invalid regular expression: invalid group specifier name
Comment 6 Vladimir Prelovac 2022-12-16 19:09:38 PST
My bad, run-minibrowser does not produce error, run-safari does, so I will assume that the problem is on my end. Thanks.