瀏覽代碼

LibWeb: Don't emit a simple selector if nothing was consumed

Andreas Kling 5 年之前
父節點
當前提交
6676f2c259
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      Libraries/LibWeb/Parser/CSSParser.cpp

+ 7 - 0
Libraries/LibWeb/Parser/CSSParser.cpp

@@ -268,6 +268,8 @@ public:
 
     Optional<Selector::SimpleSelector> parse_simple_selector()
     {
+        auto index_at_start = index;
+
         if (consume_whitespace_or_comments())
             return {};
 
@@ -397,6 +399,11 @@ public:
                 simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::Empty;
         }
 
+        if (index == index_at_start) {
+            // We consumed nothing.
+            return {};
+        }
+
         return simple_selector;
     }