From e9023427ff6486c35266f369c1249fea4779c1d0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 20 Jul 2022 19:21:06 +0200 Subject: Fix QString::toHtmlEscaped() for >2Gi character strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit More unfinished int → qsizetype porting. Manual conflict resolutions: - _L1 → QLatin1String - but keep the QLatin1Char → u'' changes as a drive-by Fixes: QTBUG-105104 Change-Id: I3470de31c476b3d7736661550916828e43546573 Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne (cherry picked from commit c1991c63fc081a42ed3e6a28f82f395c54ef42a1) --- src/corelib/text/qstring.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 9005f3267a..b5d7839693 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -10730,19 +10730,19 @@ qsizetype QtPrivate::count(QStringView haystack, const QRegularExpression &re) QString QString::toHtmlEscaped() const { QString rich; - const int len = length(); + const qsizetype len = length(); rich.reserve(qsizetype(len * 1.1)); - for (int i = 0; i < len; ++i) { - if (at(i) == QLatin1Char('<')) + for (QChar ch : *this) { + if (ch == u'<') rich += QLatin1String("<"); - else if (at(i) == QLatin1Char('>')) + else if (ch == u'>') rich += QLatin1String(">"); - else if (at(i) == QLatin1Char('&')) + else if (ch == u'&') rich += QLatin1String("&"); - else if (at(i) == QLatin1Char('"')) + else if (ch == u'"') rich += QLatin1String("""); else - rich += at(i); + rich += ch; } rich.squeeze(); return rich; -- cgit v1.2.3