Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c07d637bf0207a1427d0f0b5d0d297e90fa90825
      
https://github.com/WebKit/WebKit/commit/c07d637bf0207a1427d0f0b5d0d297e90fa90825
  Author: Daniel Liu <danl...@umich.edu>
  Date:   2025-05-22 (Thu, 22 May 2025)

  Changed paths:
    M JSTests/stress/regexp-vflag-property-of-strings.js
    M Source/JavaScriptCore/yarr/YarrParser.h
    M Source/JavaScriptCore/yarr/YarrPattern.cpp
    M Source/JavaScriptCore/yarr/YarrSyntaxChecker.cpp
    M Source/WebCore/contentextensions/URLFilterParser.cpp

  Log Message:
  -----------
  RegExp with the v flag should correctly handle nested inverted character 
classes
https://bugs.webkit.org/show_bug.cgi?id=292429
rdar://151000852

Reviewed by Michael Saboff.

Currently, we do not handle nested character classes correctly if
they are inverted. While the parser is able to work out the inner
character class needs to be inverted, this information isn't sent
to the pattern generator, meaning that it treats any nested class
as a non-inverted class. This leads to spec non-conformance. This
patch fixes that issue by adding functions to handle inversion of
a character class's matches and ranges, for ASCII and Unicode. In
the case of an inverted nested group, we invert its contents when
the closing `]` is reached.

This change also requires a small change to the parser, since its
state holds a cached character to check for potential ranges. The
cached character previously was not cleared when we read a nested
character class, meaning that its character would be processed as
part of the nested class. This would lead to bugs where character
classes would seem to ignore parts of their contents, due to that
character being cached and being treated as a part of the nested,
inverted character class.

* JSTests/stress/regexp-vflag-property-of-strings.js:
(objectToString):
(testRegExp):
(testRegExpSyntaxError):
(printErrors):
* Source/JavaScriptCore/yarr/YarrParser.h:
(JSC::Yarr::requires):
(JSC::Yarr::Parser::ClassSetParserDelegate::nestedClassBegin):
(JSC::Yarr::Parser::ClassSetParserDelegate::nestedClassEnd):
(JSC::Yarr::Parser::parseClassSet):
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::CharacterClassConstructor::invertMatches):
(JSC::Yarr::CharacterClassConstructor::asciiInvert):
(JSC::Yarr::CharacterClassConstructor::unicodeInvert):
(JSC::Yarr::YarrPatternConstructor::atomCharacterClassPushNested):
(JSC::Yarr::YarrPatternConstructor::atomCharacterClassPopNested):
* Source/JavaScriptCore/yarr/YarrSyntaxChecker.cpp:
(JSC::Yarr::SyntaxChecker::atomCharacterClassPushNested):
(JSC::Yarr::SyntaxChecker::atomCharacterClassPopNested):
* Source/WebCore/contentextensions/URLFilterParser.cpp:
(WebCore::ContentExtensions::PatternParser::atomCharacterClassPushNested):
(WebCore::ContentExtensions::PatternParser::atomCharacterClassPopNested):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to