LibWeb: Require CSS combinators to be followed by a simple selector

This commit is contained in:
Gingeh
2024-11-21 16:58:18 +11:00
committed by Andreas Kling
parent bb5678a175
commit a2cf1d17fd
2 changed files with 27 additions and 23 deletions

View File

@@ -166,8 +166,12 @@ Parser::ParseErrorOr<Optional<Selector::CompoundSelector>> Parser::parse_compoun
simple_selectors.append(component.release_value());
}
if (simple_selectors.is_empty())
if (simple_selectors.is_empty()) {
if (tokens.has_next_token() || combinator != Selector::Combinator::Descendant)
return ParseError::SyntaxError;
return Optional<Selector::CompoundSelector> {};
}
return Selector::CompoundSelector { combinator, move(simple_selectors) };
}