Bug 273254

Summary: [Yarr] Regex Lookbehinds differs from v8
Product: WebKit Reporter: Dylan Conway <dylan.conway567>
Component: JavaScriptCoreAssignee: Michael Saboff <msaboff>
Status: RESOLVED FIXED    
Severity: Normal CC: karlcow, mark.lam, mike, msaboff, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=174931

Dylan Conway
Reported 2024-04-25 10:47:21 PDT
The following text and regex will fail to replace. Using v8 it will match and replace successfully. ``` console.log("<TData = SettingsControllerGetAllResponse>(".replace(/(?<=TData = |<)(\w+(?:Error|Response))/g, "foo")); ``` Received output: "<TData = SettingsControllerGetAllResponse>(" Expected output: "<TData = foo>(" This example is minified from: https://github.com/oven-sh/bun/issues/10508
Attachments
Radar WebKit Bug Importer
Comment 1 2024-05-02 10:48:52 PDT
Karl Dubost
Comment 2 2024-05-15 01:35:27 PDT
Thanks for the report. I can confirm the output. string: "<TData = SettingsControllerGetAllResponse>(" then .replace( /(?<=TData = |<)(\w+(?:Error|Response))/g, "foo" )
Karl Dubost
Comment 3 2024-05-15 01:39:54 PDT
This gives the proper result in both Firefox and Chrome.
Karl Dubost
Comment 4 2024-05-15 01:51:14 PDT
(?<=TData = |<)(\w+(?:Error|Response))> This one is working, aka just adding ">" at the end.
Karl Dubost
Comment 5 2024-05-15 02:00:36 PDT
OK Just adding a Z on Error is making it work. (?<=TData = |<)(\w+(?:ErrorZ|Response)) It seems there's a minimum size required on the strings to match set to 6 characters. We can see that with (?<=TData = |<)(\w+(?:Respo)) FAIL (?<=TData = |<)(\w+(?:Respon)) PASS
Karl Dubost
Comment 7 2024-05-15 02:05:28 PDT
There is no threshold for Firefox and Chrome This is working for example. (?<=TData = |<)(\w+(?:R))
Michael Saboff
Comment 8 2024-05-15 09:56:18 PDT
Currently working on this bug. This issue is not the length itself of the lookbehind, but the lookbehind length relative to the remaining expression's minimum length.
Michael Saboff
Comment 9 2024-05-15 20:43:16 PDT
EWS
Comment 10 2024-05-16 08:02:11 PDT
Committed 278863@main (fafab4133900): <https://commits.webkit.org/278863@main> Reviewed commits have been landed. Closing PR #28641 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.