Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3591ed5ffe0f087d9aee7914803a518605ba43c3
      
https://github.com/WebKit/WebKit/commit/3591ed5ffe0f087d9aee7914803a518605ba43c3
  Author: Chris Dumez <[email protected]>
  Date:   2026-03-29 (Sun, 29 Mar 2026)

  Changed paths:
    M LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt
    M Source/JavaScriptCore/yarr/RegularExpression.cpp
    M Source/JavaScriptCore/yarr/RegularExpression.h
    M Source/WebCore/html/BaseTextInputType.cpp

  Log Message:
  -----------
  Avoid compiling the pattern attribute regex twice in patternMismatch()
https://bugs.webkit.org/show_bug.cgi?id=310978

Reviewed by Yusuke Suzuki and Sam Weinig.

patternMismatch() was compiling the raw pattern regex just to check
isValid(), then compiling it again with ^(?:...)$ anchoring for the
actual match. Add a MatchMode::EntireInput option to
JSC::Yarr::RegularExpression that internally validates the raw pattern
syntax via a lightweight Yarr::checkSyntax() call (parse-only, no
bytecode generation), then compiles only the anchored form. This
avoids the redundant full compilation of the raw pattern.

The raw pattern syntax must be validated separately because wrapping
with ^(?:...)$ can turn an invalid pattern into a valid one (e.g.
"a)(b" becomes "^(?:a)(b)$").

Also add a JS console message when the regular expression parsing fails,
as recommended by the specification.

* LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt:
* Source/JavaScriptCore/yarr/RegularExpression.cpp:
(JSC::Yarr::RegularExpression::Private::create):
(JSC::Yarr::RegularExpression::Private::Private):
(JSC::Yarr::RegularExpression::Private::compile):
(JSC::Yarr::RegularExpression::RegularExpression):
* Source/JavaScriptCore/yarr/RegularExpression.h:
* Source/WebCore/html/BaseTextInputType.cpp:
(WebCore::BaseTextInputType::patternMismatch const):

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



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

Reply via email to