diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-03-08 17:39:08 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-09 23:06:30 +0100 |
commit | 0371d33132a3a35a791a9d65941872ba02372b0b (patch) | |
tree | 8eed7d86c9171e01ac9ff6f6448f73d0cc18019d /Userland/Libraries/LibWeb | |
parent | a451810599f4c63c9ba6275012ecd2d33d26d2db (diff) | |
download | serenity-0371d33132a3a35a791a9d65941872ba02372b0b.zip |
LibWeb+Meta: Stop discrete media-features from parsing as ranges
Only "range" type media-features are allowed to appear in range syntax,
or have a `min-/max-` prefix.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 26bafb7251..702c3ec5c8 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -896,7 +896,7 @@ Optional<MediaFeature> Parser::parse_media_feature(TokenStream<StyleComponentVal if (allow_min_max_prefix && (name.starts_with("min-", CaseSensitivity::CaseInsensitive) || name.starts_with("max-", CaseSensitivity::CaseInsensitive))) { auto adjusted_name = name.substring_view(4); - if (auto id = media_feature_id_from_string(adjusted_name); id.has_value()) { + if (auto id = media_feature_id_from_string(adjusted_name); id.has_value() && media_feature_type_is_range(id.value())) { tokens.next_token(); return MediaFeatureName { name.starts_with("min-", CaseSensitivity::CaseInsensitive) ? MediaFeatureName::Type::Min : MediaFeatureName::Type::Max, @@ -1028,7 +1028,7 @@ Optional<MediaFeature> Parser::parse_media_feature(TokenStream<StyleComponentVal // `<mf-name> <mf-comparison> <mf-value>` // NOTE: We have to check for <mf-name> first, since all <mf-name>s will also parse as <mf-value>. - if (auto maybe_name = parse_mf_name(tokens, false); maybe_name.has_value()) { + if (auto maybe_name = parse_mf_name(tokens, false); maybe_name.has_value() && media_feature_type_is_range(maybe_name->id)) { tokens.skip_whitespace(); if (auto maybe_comparison = parse_comparison(tokens); maybe_comparison.has_value()) { tokens.skip_whitespace(); @@ -1047,7 +1047,7 @@ Optional<MediaFeature> Parser::parse_media_feature(TokenStream<StyleComponentVal tokens.skip_whitespace(); if (auto maybe_left_comparison = parse_comparison(tokens); maybe_left_comparison.has_value()) { tokens.skip_whitespace(); - if (auto maybe_name = parse_mf_name(tokens, false); maybe_name.has_value()) { + if (auto maybe_name = parse_mf_name(tokens, false); maybe_name.has_value() && media_feature_type_is_range(maybe_name->id)) { tokens.skip_whitespace(); if (!tokens.has_next_token()) |