mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:28:10 +00:00
LibRegex: Don't try to consume the escaped character if at EOF
Fixes assert on e.g. `new RegExp("\\")`
This commit is contained in:
parent
3bda458735
commit
6394720c87
2 changed files with 33 additions and 19 deletions
|
@ -1114,6 +1114,9 @@ bool ECMA262Parser::parse_atom_escape(ByteCode& stack, size_t& match_length_mini
|
|||
}
|
||||
}
|
||||
|
||||
if (done())
|
||||
return set_error(Error::InvalidTrailingEscape);
|
||||
|
||||
bool negate = false;
|
||||
auto ch = parse_character_class_escape(negate);
|
||||
if (!ch.has_value()) {
|
||||
|
@ -1211,6 +1214,11 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>&
|
|||
}
|
||||
|
||||
if (try_skip("\\")) {
|
||||
if (done()) {
|
||||
set_error(Error::InvalidTrailingEscape);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (try_skip("f"))
|
||||
return { { .code_point = '\f', .is_character_class = false } };
|
||||
if (try_skip("n"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue