diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-07-20 19:21:06 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-08-06 01:10:25 +0200 |
commit | e9023427ff6486c35266f369c1249fea4779c1d0 (patch) | |
tree | 0a5c2d3ab48003e3b005b5201844011b35511a7c | |
parent | b9e18ee4a5b97678fc9b8b1a3acd7f01858b0ebf (diff) |
Fix QString::toHtmlEscaped() for >2Gi character strings
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 <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit c1991c63fc081a42ed3e6a28f82f395c54ef42a1)
-rw-r--r-- | src/corelib/text/qstring.cpp | 14 |
1 files 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; |