From 09da5f7263e1b8fd2a141e3e2f31c8aec9d7b295 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 1 Dec 2020 15:41:30 +0100 Subject: [PATCH] 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. --- Libraries/LibWeb/CSS/Parser/CSSParser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/LibWeb/CSS/Parser/CSSParser.cpp b/Libraries/LibWeb/CSS/Parser/CSSParser.cpp index ef1884e720..e407c52e6f 100644 --- a/Libraries/LibWeb/CSS/Parser/CSSParser.cpp +++ b/Libraries/LibWeb/CSS/Parser/CSSParser.cpp @@ -909,6 +909,11 @@ public: RefPtr 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()) { parse_rule(); }