Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 98d0367d2247df6cfc363a38eadc33fa2ce1723e
      
https://github.com/WebKit/WebKit/commit/98d0367d2247df6cfc363a38eadc33fa2ce1723e
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-07-27 (Mon, 27 Jul 2026)

  Changed paths:
    A JSTests/stress/regexp-bol-inside-parentheses-is-not-anchored.js
    M Source/JavaScriptCore/yarr/YarrPattern.cpp

  Log Message:
  -----------
  [YARR] A ^ inside a parenthesis that can match empty does not anchor the 
pattern
https://bugs.webkit.org/show_bug.cgi?id=320347
rdar://183300022

Reviewed by Yijia Huang.

/(?:^a)?b/ is incorrectly working since it is marked as m_startsWithBOL.
But we need to ensure that ^ parentheses does not pass with empty input.
This patch correctly recomputes m_startsWithBOL flag by scanning
alternatives.

We also fixes copyDisjunction too. The current one is incorrectly
dropping ^ pattern in the middle, so /x(?:^a)b/ becomes /xb/, but this
is not correct. We should use only when all copies succeed.

Test: JSTests/stress/regexp-bol-inside-parentheses-is-not-anchored.js

* JSTests/stress/regexp-bol-inside-parentheses-is-not-anchored.js: Added.
(shouldBe):
(check):
(step):
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::atomParenthesesEnd):
(JSC::Yarr::YarrPatternConstructor::copyDisjunction):
(JSC::Yarr::YarrPatternConstructor::parenthesesMustMatch):
(JSC::Yarr::YarrPatternConstructor::copyTerms):
(JSC::Yarr::YarrPatternConstructor::recomputeStartsWithBOL):
(JSC::Yarr::YarrPatternConstructor::optimizeBOL):
(JSC::Yarr::YarrPatternConstructor::optimizeDotStarWrappedExpressions):
(JSC::Yarr::YarrPattern::compile):

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



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

Reply via email to