瀏覽代碼

LibWeb: Fix greedy CSS Tokenizer whitespace parsing

Whitespace parsing was too greedy, consuming the first non-
whitespace character after it.
Sam Atkins 4 年之前
父節點
當前提交
9115c23bd5
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp

+ 4 - 1
Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp

@@ -725,8 +725,11 @@ Token Tokenizer::consume_a_token()
     if (is_whitespace(input)) {
         dbgln_if(CSS_TOKENIZER_TRACE, "is whitespace");
 
-        while (is_whitespace(peek_code_point().value()))
+        auto next = peek_code_point();
+        while (next.has_value() && is_whitespace(next.value())) {
             (void)next_code_point();
+            next = peek_code_point();
+        }
 
         return create_new_token(Token::TokenType::Whitespace);
     }