WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
273254
[Yarr] Regex Lookbehinds differs from v8
https://bugs.webkit.org/show_bug.cgi?id=273254
Summary
[Yarr] Regex Lookbehinds differs from v8
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
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-05-02 10:48:52 PDT
<
rdar://problem/127440248
>
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 6
2024-05-15 02:02:42 PDT
This? const size_t thresholdForBinarySearch = 6;
https://searchfox.org/wubkat/rev/7051b8f5cd90af80f03a58d74741cdb04c800b6e/Source/JavaScriptCore/yarr/YarrInterpreter.cpp#520
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
Pull request:
https://github.com/WebKit/WebKit/pull/28641
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.
Top of Page
Format For Printing
XML
Clone This Bug