Forráskód Böngészése

LibWeb: Hack the CSS parser to skip over UTF-8 BOM

This is a rather ugly hack that fixes CSS parsing on websites where we
get a stylesheet that starts with a BOM.
Andreas Kling 4 éve
szülő
commit
09da5f7263
1 módosított fájl, 5 hozzáadás és 0 törlés
  1. 5 0
      Libraries/LibWeb/CSS/Parser/CSSParser.cpp

+ 5 - 0
Libraries/LibWeb/CSS/Parser/CSSParser.cpp

@@ -909,6 +909,11 @@ public:
 
 
     RefPtr<CSS::StyleSheet> parse_sheet()
     RefPtr<CSS::StyleSheet> parse_sheet()
     {
     {
+        if (peek(0) == (char)0xef && peek(1) == (char)0xbb && peek(2) == (char)0xbf) {
+            // HACK: Skip UTF-8 BOM.
+            index += 3;
+        }
+
         while (index < css.length()) {
         while (index < css.length()) {
             parse_rule();
             parse_rule();
         }
         }