LibWeb: Correct parsing invalid list of declarations

We were only discarding at most one token when a declaration is
invalid, when we should discard all until we see a ; or EOF.
This commit is contained in:
Sam Atkins 2021-07-09 20:08:09 +01:00 committed by Andreas Kling
commit 86994336a7
Notes: sideshowbarker 2024-07-18 09:13:03 +09:00

View file

@ -890,8 +890,10 @@ Vector<DeclarationOrAtRule> Parser::consume_a_list_of_declarations(TokenStream<T
log_parse_error();
tokens.reconsume_current_input_token();
auto peek = tokens.peek_token();
if (!(peek.is(Token::Type::Semicolon) || peek.is(Token::Type::EndOfFile))) {
while (!(peek.is(Token::Type::Semicolon) || peek.is(Token::Type::EndOfFile))) {
dbgln("Discarding token: '{}'", peek.to_debug_string());
(void)consume_a_component_value(tokens);
peek = tokens.peek_token();
}
}