mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00: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
2 changed files with 22 additions and 0 deletions
|
@ -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)
|
TEST_CASE(ECMA262_unicode_sets_match)
|
||||||
{
|
{
|
||||||
struct _test {
|
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
|
"&&"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();
|
auto start_position = tell();
|
||||||
ArmedScopeGuard restore { [&] { back(tell() - start_position + 1); } };
|
ArmedScopeGuard restore { [&] { back(tell() - start_position + 1); } };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue