summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-02 11:43:54 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-02 11:48:00 +0200
commit21bc5fdec37f6c19377044147f75b23c1c1a9ea6 (patch)
treea3b534842b27d3a3f2d26e0b50c2dd2e70957543 /Userland/Libraries/LibWeb/CSS
parent3e3d196f06e5396fe794dca9715a76b21266cbc3 (diff)
downloadserenity-21bc5fdec37f6c19377044147f75b23c1c1a9ea6.zip
LibWeb: Don't interpreter invalid CSS pseudo-classes as '*' selector
Bogus pseudo-classes like ":bogus" would actually match every element.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp
index 3c6b0e15f3..365ed0eee2 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp
@@ -536,28 +536,32 @@ public:
if (is_pseudo_element)
return {};
- if (pseudo_name.equals_ignoring_case("link"))
+ if (pseudo_name.equals_ignoring_case("link")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Link;
- else if (pseudo_name.equals_ignoring_case("visited"))
+ } else if (pseudo_name.equals_ignoring_case("visited")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Visited;
- else if (pseudo_name.equals_ignoring_case("hover"))
+ } else if (pseudo_name.equals_ignoring_case("hover")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Hover;
- else if (pseudo_name.equals_ignoring_case("focus"))
+ } else if (pseudo_name.equals_ignoring_case("focus")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Focus;
- else if (pseudo_name.equals_ignoring_case("first-child"))
+ } else if (pseudo_name.equals_ignoring_case("first-child")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::FirstChild;
- else if (pseudo_name.equals_ignoring_case("last-child"))
+ } else if (pseudo_name.equals_ignoring_case("last-child")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::LastChild;
- else if (pseudo_name.equals_ignoring_case("only-child"))
+ } else if (pseudo_name.equals_ignoring_case("only-child")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::OnlyChild;
- else if (pseudo_name.equals_ignoring_case("empty"))
+ } else if (pseudo_name.equals_ignoring_case("empty")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Empty;
- else if (pseudo_name.equals_ignoring_case("root"))
+ } else if (pseudo_name.equals_ignoring_case("root")) {
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Root;
- else if (pseudo_name.equals_ignoring_case("before"))
+ } else if (pseudo_name.equals_ignoring_case("before")) {
simple_selector.pseudo_element = CSS::Selector::SimpleSelector::PseudoElement::Before;
- else if (pseudo_name.equals_ignoring_case("after"))
+ } else if (pseudo_name.equals_ignoring_case("after")) {
simple_selector.pseudo_element = CSS::Selector::SimpleSelector::PseudoElement::After;
+ } else {
+ dbgln("Unknown pseudo class: '{}'", pseudo_name);
+ return {};
+ }
}
if (index == index_at_start) {
@@ -1008,5 +1012,4 @@ RefPtr<CSS::StyleValue> parse_html_length(const DOM::Document& document, const S
return CSS::LengthStyleValue::create(CSS::Length::make_px(integer.value()));
return parse_css_value(CSS::ParsingContext(document), string);
}
-
}