mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-25 04:22:50 +00:00
LibWeb: Disallow "default" as a <family-name>
identifier
This commit disallows "default" as a font-family name, when the name is not quoted because unquoted names are treated as custom-idents, for which the name "default" is not allowed.
This commit is contained in:
parent
263cb3f8ca
commit
408f9f3dde
Notes:
github-actions[bot]
2025-04-07 11:15:29 +00:00
Author: https://github.com/tcl3
Commit: 408f9f3dde
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4235
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/gmta
4 changed files with 2545 additions and 26 deletions
|
@ -361,17 +361,6 @@ RefPtr<CSSStyleValue> Parser::parse_family_name_value(TokenStream<ComponentValue
|
|||
|
||||
if (peek.is(Token::Type::Ident)) {
|
||||
auto ident = tokens.consume_a_token().token().ident();
|
||||
|
||||
// CSS-wide keywords are not allowed
|
||||
if (is_css_wide_keyword(ident))
|
||||
return nullptr;
|
||||
|
||||
// <generic-family> is a separate type from <family-name>, and so isn't allowed here.
|
||||
auto maybe_keyword = keyword_from_string(ident);
|
||||
if (maybe_keyword.has_value() && keyword_to_generic_font_family(maybe_keyword.value()).has_value()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
parts.append(ident.to_string());
|
||||
tokens.discard_whitespace();
|
||||
continue;
|
||||
|
@ -383,8 +372,19 @@ RefPtr<CSSStyleValue> Parser::parse_family_name_value(TokenStream<ComponentValue
|
|||
if (parts.is_empty())
|
||||
return nullptr;
|
||||
|
||||
if (parts.size() == 1) {
|
||||
// <generic-family> is a separate type from <family-name>, and so isn't allowed here.
|
||||
auto maybe_keyword = keyword_from_string(parts.first());
|
||||
if (is_css_wide_keyword(parts.first()) || parts.first().equals_ignoring_ascii_case("default"sv))
|
||||
return nullptr;
|
||||
if (maybe_keyword.has_value() && keyword_to_generic_font_family(maybe_keyword.value()).has_value())
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto complete_name = MUST(String::join(' ', parts));
|
||||
|
||||
transaction.commit();
|
||||
return CustomIdentStyleValue::create(MUST(String::join(' ', parts)));
|
||||
return CustomIdentStyleValue::create(complete_name);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-syntax-3/#urange-syntax
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue