From 1753d696070895f309c46ba5aee662b0f3a18bde Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Sat, 15 Oct 2016 14:14:00 +0200 Subject: [PATCH] QCss: Fix parsing of charset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When including a CSS file in a HTML file sent to QTextDocument, and the CSS file starts with «@charset "UTF-8";», which is the correct way of declaring that, the parsing fails. If you omit the space, like «@charset"UTF-8";» the parsing succeeds, which is wrong. Fix this by expecting and swallowing whitespace after the @charset tokens. Task-number: QTBUG-54829 Change-Id: I32044e8d24bda70c1eb06bf74af50d4cabe2211d Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qcssparser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index e96aecdf68..3d6acccdb8 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -2175,6 +2175,7 @@ void Parser::init(const QString &css, bool isFile) bool Parser::parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity) { if (testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("charset"))) { + while (test(S) || test(CDO) || test(CDC)) {} if (!next(STRING)) return false; if (!next(SEMICOLON)) return false; }