summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@gmail.com>2021-07-28 17:02:37 +0100
committerAndreas Kling <kling@serenityos.org>2021-07-31 00:18:11 +0200
commit4c4482c7f65ace11a05b2c52c8c884a4cf3cb481 (patch)
treee15d955a1fa493b46c6d1a560090baaa03df2554 /Userland/Libraries/LibWeb
parentd113bc7704db9e1356c9575152c6d3c78d0c4fc6 (diff)
downloadserenity-4c4482c7f65ace11a05b2c52c8c884a4cf3cb481.zip
LibWeb: Ignore unquoted data urls in CSS
Previously we were only ignoring quoted ones (eg `url("data:...")`), so now we ignore unquoted ones (eg `url(data:...)`) too.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index a2b2f2a4b3..0b1494d7a7 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -1197,9 +1197,18 @@ Vector<Vector<StyleComponentValueRule>> Parser::parse_as_comma_separated_list_of
Optional<URL> Parser::parse_url_function(ParsingContext const& context, StyleComponentValueRule const& component_value)
{
// FIXME: Handle list of media queries. https://www.w3.org/TR/css-cascade-3/#conditional-import
+ // FIXME: Handle data: urls (RFC2397)
- if (component_value.is(Token::Type::Url))
- return context.complete_url(component_value.token().url());
+ auto is_data_url = [](StringView& url_string) -> bool {
+ return url_string.starts_with("data:", CaseSensitivity::CaseInsensitive);
+ };
+
+ if (component_value.is(Token::Type::Url)) {
+ auto url_string = component_value.token().url();
+ if (is_data_url(url_string))
+ return {};
+ return context.complete_url(url_string);
+ }
if (component_value.is_function() && component_value.function().name().equals_ignoring_case("url")) {
auto& function_values = component_value.function().values();
// FIXME: Handle url-modifiers. https://www.w3.org/TR/css-values-4/#url-modifiers
@@ -1208,11 +1217,12 @@ Optional<URL> Parser::parse_url_function(ParsingContext const& context, StyleCom
if (value.is(Token::Type::Whitespace))
continue;
if (value.is(Token::Type::String)) {
- // FIXME: RFC2397
- if (value.token().string().starts_with("data:"))
- break;
- return context.complete_url(value.token().string());
+ auto url_string = value.token().string();
+ if (is_data_url(url_string))
+ return {};
+ return context.complete_url(url_string);
}
+ break;
}
}