mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibRegex: Track local compares in nested classes
This commit is contained in:
parent
f54793315c
commit
8c9c2ee289
Notes:
github-actions[bot]
2025-11-01 13:39:13 +00:00
Author: https://github.com/aplefull
Commit: 8c9c2ee289
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6660
Reviewed-by: https://github.com/alimpfard ✅
2 changed files with 5 additions and 2 deletions
|
|
@ -2418,6 +2418,7 @@ bool ECMA262Parser::parse_nested_class(Vector<regex::CompareTypeAndValuePair>& c
|
|||
if (match(TokenType::LeftBracket)) {
|
||||
consume();
|
||||
|
||||
auto initial_compares_size = compares.size();
|
||||
compares.append(CompareTypeAndValuePair { CharacterCompareType::Or, 0 });
|
||||
|
||||
if (match(TokenType::Circumflex)) {
|
||||
|
|
@ -2429,12 +2430,13 @@ bool ECMA262Parser::parse_nested_class(Vector<regex::CompareTypeAndValuePair>& c
|
|||
// ClassContents :: [empty]
|
||||
if (match(TokenType::RightBracket)) {
|
||||
consume();
|
||||
auto added_compares = compares.size() - initial_compares_size;
|
||||
// Should only have at most an 'Inverse' (after an 'Or')
|
||||
if (m_parser_state.regex_options.has_flag_set(regex::AllFlags::UnicodeSets)) {
|
||||
// In unicode sets mode, we can have an additional 'And'/'Or' before the 'Inverse'.
|
||||
VERIFY(compares.size() <= 3);
|
||||
VERIFY(added_compares <= 3);
|
||||
} else {
|
||||
VERIFY(compares.size() <= 2);
|
||||
VERIFY(added_compares <= 2);
|
||||
}
|
||||
compares.append(CompareTypeAndValuePair { CharacterCompareType::EndAndOr, 0 });
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -891,6 +891,7 @@ TEST_CASE(ECMA262_unicode_sets_match)
|
|||
{ "[\\w&&\\d]"sv, "a"sv, false },
|
||||
{ "[\\w&&\\d]"sv, "4"sv, true },
|
||||
{ "([^\\:]+?)"sv, "a"sv, true },
|
||||
{ "[[a][]]"sv, "a"sv, true }, // ladybird#6647
|
||||
};
|
||||
|
||||
for (auto& test : tests) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue