Fix QString::toHtmlEscaped() for >2Gi character strings

More unfinished int → qsizetype porting.

Fixes: QTBUG-105104
Pick-to: 6.4 6.3 6.2
Change-Id: I3470de31c476b3d7736661550916828e43546573
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Marc Mutz 2022-07-20 19:21:06 +02:00
parent 929bb153ee
commit c1991c63fc

View File

@ -10896,19 +10896,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) == u'<')
for (QChar ch : *this) {
if (ch == u'<')
rich += "&lt;"_L1;
else if (at(i) == u'>')
else if (ch == u'>')
rich += "&gt;"_L1;
else if (at(i) == u'&')
else if (ch == u'&')
rich += "&amp;"_L1;
else if (at(i) == u'"')
else if (ch == u'"')
rich += "&quot;"_L1;
else
rich += at(i);
rich += ch;
}
rich.squeeze();
return rich;