summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtexthtmlparser.cpp
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2021-12-15 15:10:00 +0100
committerOliver Eftevaag <oliver.eftevaag@qt.io>2021-12-22 15:56:30 +0100
commitb369dc6021e83e70b95d04f886cfda4dfcf56c45 (patch)
tree2b21d66dfded8ec597fc9569c17764b01277ec39 /src/gui/text/qtexthtmlparser.cpp
parent0462d24dcd851222d4ac73e7af38d785c6a32cfd (diff)
QTextHtmlParser: fix prefix lookahead and html comments
The hasPrefix() function would only use the second 'lookahead' parameter to check if there was more unparsed text after the current character. When it's obvious from the codebase that it should actually look ahead of the current character being processed, and compare againt that future character. Html comments were also not handled quite right. Partially because of the broken hasPrefix() function, but also because it would advance the current index tracker by 3 instead of 2. Remember that the beginning of an html comment is <!-- meaning that there are only supposed to be 2 dashes required, not 3. The result would be that something like this <!----> would not automatically close, because the current index tracker would jump over the first 3 dashes when it begins a comment, and the remaining unprocessed string would be -> Also, because of the broken lookahead in hasPrefix(), a comment could actually be started with just <!- not requiring a second dash at all. Pick-to: 6.3 6.2 5.15 Fixes: QTBUG-99147 Change-Id: I8f4d4a1107eaf2dae16d16b7b860525d45a1c474 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/text/qtexthtmlparser.cpp')
-rw-r--r--src/gui/text/qtexthtmlparser.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 85877bfe47..f97b8a672a 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -785,8 +785,8 @@ void QTextHtmlParser::parseCloseTag()
void QTextHtmlParser::parseExclamationTag()
{
++pos;
- if (hasPrefix(QLatin1Char('-'),1) && hasPrefix(QLatin1Char('-'),2)) {
- pos += 3;
+ if (hasPrefix(QLatin1Char('-')) && hasPrefix(QLatin1Char('-'), 1)) {
+ pos += 2;
// eat comments
int end = txt.indexOf(QLatin1String("-->"), pos);
pos = (end >= 0 ? end + 3 : len);
@@ -882,7 +882,7 @@ QString QTextHtmlParser::parseWord()
while (pos < len) {
QChar c = txt.at(pos++);
if (c == QLatin1Char('>')
- || (c == QLatin1Char('/') && hasPrefix(QLatin1Char('>'), 1))
+ || (c == QLatin1Char('/') && hasPrefix(QLatin1Char('>')))
|| c == QLatin1Char('<')
|| c == QLatin1Char('=')
|| c.isSpace()) {