1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibRegex: Make unclosed-at-eof brace quantifiers an error

Otherwise we'd just loop trying to parse it over and over again, for
instance in `/a{/` or `/a{1,/`.
Unless we're parsing in Annex B mode, which allows `{` as a normal
ExtendedSourceCharacter.
This commit is contained in:
Ali Mohammad Pur 2021-07-24 13:00:14 +04:30 committed by Ali Mohammad Pur
parent 1dd1378159
commit faef523567

View file

@ -1153,7 +1153,10 @@ bool ECMA262Parser::parse_quantifier(ByteCode& stack, size_t& match_length_minim
auto low_bound = low_bound_string.to_uint();
if (!low_bound.has_value()) {
back(chars_consumed + 1);
if (!m_should_use_browser_extended_grammar && done())
return set_error(Error::MismatchingBrace);
back(chars_consumed + !done());
return true;
}
@ -1173,7 +1176,10 @@ bool ECMA262Parser::parse_quantifier(ByteCode& stack, size_t& match_length_minim
}
if (!match(TokenType::RightCurly)) {
back(chars_consumed + 1);
if (!m_should_use_browser_extended_grammar && done())
return set_error(Error::MismatchingBrace);
back(chars_consumed + !done());
return true;
}
@ -1297,7 +1303,7 @@ bool ECMA262Parser::parse_invalid_braced_quantifier()
StringView high_bound;
if (low_bound.is_empty()) {
back(chars_consumed + 1);
back(chars_consumed + !done());
return false;
}
chars_consumed += low_bound.length();
@ -1310,7 +1316,7 @@ bool ECMA262Parser::parse_invalid_braced_quantifier()
}
if (!match(TokenType::RightCurly)) {
back(chars_consumed + 1);
back(chars_consumed + !done());
return false;
}