Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 29d016fbd9f466795ace2e38d9508523633202e7
      
https://github.com/WebKit/WebKit/commit/29d016fbd9f466795ace2e38d9508523633202e7
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-08-02 (Sun, 02 Aug 2026)

  Changed paths:
    A 
JSTests/stress/regexp-lookahead-with-bol-inside-lookbehind-is-not-dropped.js
    M Source/JavaScriptCore/yarr/YarrPattern.cpp

  Log Message:
  -----------
  [YARR] Do not filter the contents of a lookbehind in `optimizeBOL`
https://bugs.webkit.org/show_bug.cgi?id=320722

Reviewed by Yusuke Suzuki.

    /(?<=(?=^)a)b|c/.exec("ab") // null, should be ["b"]

optimizeBOL()'s loop copy drops alternatives that can only match at the start of
the input. A lookbehind walks backwards from the match position, so a ^ inside 
it
can reach position 0 even when the match itself starts later.

copyDisjunction() exempted Backward alternatives, but a lookahead nested inside 
a
lookbehind is parsed as Forward again, so its ^-anchored alternative was 
filtered
out and the whole lookbehind-containing alternative got dropped from the loop 
copy.

copyTerm() now stops filtering at any Backward term instead, which subsumes the
per-alternative exemption in copyDisjunction().

Test: 
JSTests/stress/regexp-lookahead-with-bol-inside-lookbehind-is-not-dropped.js

* JSTests/stress/regexp-lookahead-with-bol-inside-lookbehind-is-not-dropped.js: 
Added.
(shouldBe):
(check):
(step):
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::copyDisjunction):
(JSC::Yarr::YarrPatternConstructor::copyTerm):

Canonical link: https://commits.webkit.org/318418@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to