mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibRegex: Account for extra explicit And/Or in class parser assertion
Fixes #23691.
This commit is contained in:
parent
259a84ddac
commit
27a38932da
Notes:
sideshowbarker
2024-07-17 04:01:41 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/27a38932da Pull-request: https://github.com/SerenityOS/serenity/pull/23694 Issue: https://github.com/SerenityOS/serenity/issues/23691
2 changed files with 7 additions and 1 deletions
|
@ -800,6 +800,7 @@ TEST_CASE(ECMA262_unicode_sets_parser_error)
|
||||||
|
|
||||||
constexpr _test tests[] {
|
constexpr _test tests[] {
|
||||||
{ "[[]"sv, regex::Error::InvalidPattern },
|
{ "[[]"sv, regex::Error::InvalidPattern },
|
||||||
|
{ "[[x[]]]"sv, regex::Error::NoError }, // #23691, should not crash on empty charclass within AndOr.
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto test : tests) {
|
for (auto test : tests) {
|
||||||
|
|
|
@ -2386,7 +2386,12 @@ bool ECMA262Parser::parse_nested_class(Vector<regex::CompareTypeAndValuePair>& c
|
||||||
if (match(TokenType::RightBracket)) {
|
if (match(TokenType::RightBracket)) {
|
||||||
consume();
|
consume();
|
||||||
// Should only have at most an 'Inverse' (after an 'Or')
|
// 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);
|
||||||
|
} else {
|
||||||
VERIFY(compares.size() <= 2);
|
VERIFY(compares.size() <= 2);
|
||||||
|
}
|
||||||
compares.append(CompareTypeAndValuePair { CharacterCompareType::EndAndOr, 0 });
|
compares.append(CompareTypeAndValuePair { CharacterCompareType::EndAndOr, 0 });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue