LibWeb/CSS: Ensure a font source format() only contains one string/ident

This commit is contained in:
Sam Atkins 2025-04-15 11:04:04 +01:00
parent 90deecad3d
commit b800532e54
2 changed files with 11 additions and 5 deletions

View file

@ -3711,6 +3711,12 @@ RefPtr<FontSourceStyleValue> Parser::parse_font_source_value(TokenStream<Compone
return nullptr;
}
format_tokens.discard_whitespace();
if (format_tokens.has_next_token()) {
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: font source invalid (`format()` has trailing tokens); discarding.");
return nullptr;
}
format = move(format_name);
}

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 35 tests
30 Pass
5 Fail
33 Pass
2 Fail
Pass Check that src: url("foo.ttf") is valid
Pass Check that src: url("foo.ttf"), url("bar.ttf") is valid
Pass Check that src: url("foo.ttf") format() is invalid
@ -15,14 +15,14 @@ Pass Check that src: url("foo.ttf") format("opentype") is valid
Pass Check that src: url("foo.ttf") format("truetype") is valid
Pass Check that src: url("foo.ttf") format("woff") is valid
Pass Check that src: url("foo.ttf") format("woff2") is valid
Fail Check that src: url("foo.ttf") format("opentype", "truetype") is invalid
Pass Check that src: url("foo.ttf") format("opentype", "truetype") is invalid
Fail Check that src: url("foo.ttf") format(collection) is valid
Pass Check that src: url("foo.ttf") format(opentype) is valid
Pass Check that src: url("foo.ttf") format(truetype) is valid
Pass Check that src: url("foo.ttf") format(woff) is valid
Pass Check that src: url("foo.ttf") format(woff2) is valid
Fail Check that src: url("foo.ttf") format(opentype, truetype) is invalid
Fail Check that src: url("foo.ttf") format(opentype truetype) is invalid
Pass Check that src: url("foo.ttf") format(opentype, truetype) is invalid
Pass Check that src: url("foo.ttf") format(opentype truetype) is invalid
Pass Check that src: url("foo.ttf") format(auto) is invalid
Pass Check that src: url("foo.ttf") format(default) is invalid
Pass Check that src: url("foo.ttf") format(inherit) is invalid