mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibRegex: Bail parsing class set characters upon early EOF
Otherwise, we reach a skip() invocation at the end of this function, which crashes due to EOF. Caught by test262.
This commit is contained in:
parent
32502fceed
commit
8b668da9d5
Notes:
sideshowbarker
2024-07-16 23:57:20 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/8b668da9d5 Pull-request: https://github.com/SerenityOS/serenity/pull/19583 Reviewed-by: https://github.com/alimpfard ✅
@ -779,6 +779,23 @@ TEST_CASE(ECMA262_unicode_match)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(ECMA262_unicode_sets_parser_error)
|
||||
{
|
||||
struct _test {
|
||||
StringView pattern;
|
||||
regex::Error error;
|
||||
};
|
||||
|
||||
constexpr _test tests[] {
|
||||
{ "[[]"sv, regex::Error::InvalidPattern },
|
||||
};
|
||||
|
||||
for (auto test : tests) {
|
||||
Regex<ECMA262> re(test.pattern, (ECMAScriptFlags)regex::AllFlags::UnicodeSets);
|
||||
EXPECT_EQ(re.parser_result.error, test.error);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(ECMA262_unicode_sets_match)
|
||||
{
|
||||
struct _test {
|
||||
|
@ -2224,6 +2224,11 @@ Optional<u32> ECMA262Parser::parse_class_set_character()
|
||||
"&&"sv, "!!"sv, "##"sv, "$$"sv, "%%"sv, "**"sv, "++"sv, ",,"sv, ".."sv, "::"sv, ";;"sv, "<<"sv, "=="sv, ">>"sv, "??"sv, "@@"sv, "^^"sv, "``"sv, "~~"sv
|
||||
};
|
||||
|
||||
if (done()) {
|
||||
set_error(Error::InvalidPattern);
|
||||
return {};
|
||||
}
|
||||
|
||||
auto start_position = tell();
|
||||
ArmedScopeGuard restore { [&] { back(tell() - start_position + 1); } };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user