QtNetwork: stop using QLatin1Char constructor for creating char literals

Required for porting away from QLatin1Char/QLatin1String in scope of
QTBUG-98434.

As a drive-by, fix qsizetype -> int narrowing conversion warnings for
the touched lines.

Change-Id: I121f87214b77aeab1dfd3e62dc5adaa6255cc0e0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Sona Kurazyan 2022-04-12 14:01:55 +02:00
parent e2a1329910
commit f2637e1a77
22 changed files with 63 additions and 66 deletions

View File

@ -210,7 +210,7 @@ bool QHstsCache::isKnownHost(const QUrl &url) const
} }
} }
const int dot = nameToTest.fragment.indexOf(QLatin1Char('.')); const qsizetype dot = nameToTest.fragment.indexOf(u'.');
if (dot == -1) if (dot == -1)
break; break;

View File

@ -172,7 +172,7 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy, const QString &p
Q_UNUSED(proxy); Q_UNUSED(proxy);
#endif #endif
if (!peerVerifyName.isEmpty()) if (!peerVerifyName.isEmpty())
result += QLatin1Char(':') + peerVerifyName; result += u':' + peerVerifyName;
return "http-connection:" + std::move(result).toLatin1(); return "http-connection:" + std::move(result).toLatin1();
} }

View File

@ -131,7 +131,7 @@ void QNetworkAccessFileBackend::open()
QString fileName = url.toLocalFile(); QString fileName = url.toLocalFile();
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
if (url.scheme() == QLatin1String("qrc")) { if (url.scheme() == QLatin1String("qrc")) {
fileName = QLatin1Char(':') + url.path(); fileName = u':' + url.path();
} else { } else {
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
if (url.scheme() == QLatin1String("assets")) if (url.scheme() == QLatin1String("assets"))

View File

@ -541,7 +541,7 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const
} }
if (!d->domain.isEmpty()) { if (!d->domain.isEmpty()) {
result += "; domain="; result += "; domain=";
if (d->domain.startsWith(QLatin1Char('.'))) { if (d->domain.startsWith(u'.')) {
result += '.'; result += '.';
result += QUrl::toAce(d->domain.mid(1)); result += QUrl::toAce(d->domain.mid(1));
} else { } else {
@ -1028,7 +1028,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt
if (!rawDomain.isEmpty()) { if (!rawDomain.isEmpty()) {
QString maybeLeadingDot; QString maybeLeadingDot;
if (rawDomain.startsWith('.')) { if (rawDomain.startsWith('.')) {
maybeLeadingDot = QLatin1Char('.'); maybeLeadingDot = u'.';
rawDomain = rawDomain.mid(1); rawDomain = rawDomain.mid(1);
} }
@ -1096,9 +1096,9 @@ void QNetworkCookie::normalize(const QUrl &url)
// don't do path checking. See QTBUG-5815 // don't do path checking. See QTBUG-5815
if (d->path.isEmpty()) { if (d->path.isEmpty()) {
QString pathAndFileName = url.path(); QString pathAndFileName = url.path();
QString defaultPath = pathAndFileName.left(pathAndFileName.lastIndexOf(QLatin1Char('/'))+1); QString defaultPath = pathAndFileName.left(pathAndFileName.lastIndexOf(u'/') + 1);
if (defaultPath.isEmpty()) if (defaultPath.isEmpty())
defaultPath = QLatin1Char('/'); defaultPath = u'/';
d->path = defaultPath; d->path = defaultPath;
} }
@ -1108,12 +1108,12 @@ void QNetworkCookie::normalize(const QUrl &url)
QHostAddress hostAddress(d->domain); QHostAddress hostAddress(d->domain);
if (hostAddress.protocol() != QAbstractSocket::IPv4Protocol if (hostAddress.protocol() != QAbstractSocket::IPv4Protocol
&& hostAddress.protocol() != QAbstractSocket::IPv6Protocol && hostAddress.protocol() != QAbstractSocket::IPv6Protocol
&& !d->domain.startsWith(QLatin1Char('.'))) { && !d->domain.startsWith(u'.')) {
// Ensure the domain starts with a dot if its field was not empty // Ensure the domain starts with a dot if its field was not empty
// in the HTTP header. There are some servers that forget the // in the HTTP header. There are some servers that forget the
// leading dot and this is actually forbidden according to RFC 2109, // leading dot and this is actually forbidden according to RFC 2109,
// but all browsers accept it anyway so we do that as well. // but all browsers accept it anyway so we do that as well.
d->domain.prepend(QLatin1Char('.')); d->domain.prepend(u'.');
} }
} }
} }

View File

@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
static bool qIsEffectiveTLD(QStringView domain) static bool qIsEffectiveTLD(QStringView domain)
{ {
// provide minimal checking by not accepting cookies on real TLDs // provide minimal checking by not accepting cookies on real TLDs
return !domain.contains(QLatin1Char('.')); return !domain.contains(u'.');
} }
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif
@ -167,7 +167,7 @@ static inline bool isParentPath(const QString &path, const QString &reference)
static inline bool isParentDomain(const QString &domain, const QString &reference) static inline bool isParentDomain(const QString &domain, const QString &reference)
{ {
if (!reference.startsWith(QLatin1Char('.'))) if (!reference.startsWith(u'.'))
return domain == reference; return domain == reference;
return domain.endsWith(reference) || domain == QStringView{reference}.mid(1); return domain.endsWith(reference) || domain == QStringView{reference}.mid(1);
@ -250,13 +250,13 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const
continue; continue;
QString domain = it->domain(); QString domain = it->domain();
if (domain.startsWith(QLatin1Char('.'))) /// Qt6?: remove when compliant with RFC6265 if (domain.startsWith(u'.')) /// Qt6?: remove when compliant with RFC6265
domain = domain.mid(1); domain = domain.mid(1);
#if QT_CONFIG(topleveldomain) #if QT_CONFIG(topleveldomain)
if (qIsEffectiveTLD(domain) && url.host() != domain) if (qIsEffectiveTLD(domain) && url.host() != domain)
continue; continue;
#else #else
if (!domain.contains(QLatin1Char('.')) && url.host() != domain) if (!domain.contains(u'.') && url.host() != domain)
continue; continue;
#endif // topleveldomain #endif // topleveldomain
@ -356,7 +356,7 @@ bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl
if (!isParentDomain(domain, host) && !isParentDomain(host, domain)) if (!isParentDomain(domain, host) && !isParentDomain(host, domain))
return false; // not accepted return false; // not accepted
if (domain.startsWith(QLatin1Char('.'))) if (domain.startsWith(u'.'))
domain = domain.mid(1); domain = domain.mid(1);
// We shouldn't reject if: // We shouldn't reject if:

View File

@ -148,10 +148,10 @@ void QNetworkDiskCache::setCacheDirectory(const QString &cacheDir)
d->cacheDirectory = cacheDir; d->cacheDirectory = cacheDir;
QDir dir(d->cacheDirectory); QDir dir(d->cacheDirectory);
d->cacheDirectory = dir.absolutePath(); d->cacheDirectory = dir.absolutePath();
if (!d->cacheDirectory.endsWith(QLatin1Char('/'))) if (!d->cacheDirectory.endsWith(u'/'))
d->cacheDirectory += QLatin1Char('/'); d->cacheDirectory += u'/';
d->dataDirectory = d->cacheDirectory + DATA_DIR + QString::number(CACHE_VERSION) + QLatin1Char('/'); d->dataDirectory = d->cacheDirectory + DATA_DIR + QString::number(CACHE_VERSION) + u'/';
d->prepareLayout(); d->prepareLayout();
} }
@ -598,8 +598,7 @@ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url)
const QByteArray id = QByteArray::number(*(qlonglong*)hash.data(), 36).left(8); const QByteArray id = QByteArray::number(*(qlonglong*)hash.data(), 36).left(8);
// generates <one-char subdir>/<8-char filname.d> // generates <one-char subdir>/<8-char filname.d>
uint code = (uint)id.at(id.length()-1) % 16; uint code = (uint)id.at(id.length()-1) % 16;
QString pathFragment = QString::number(code, 16) + QLatin1Char('/') QString pathFragment = QString::number(code, 16) + u'/' + QLatin1String(id) + CACHE_POSTFIX;
+ QLatin1String(id) + CACHE_POSTFIX;
return pathFragment; return pathFragment;
} }

View File

@ -105,7 +105,7 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
const QString scheme = url.scheme(); const QString scheme = url.scheme();
if (scheme == QLatin1String("qrc")) { if (scheme == QLatin1String("qrc")) {
fileName = QLatin1Char(':') + url.path(); fileName = u':' + url.path();
} else { } else {
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
if (scheme == QLatin1String("assets")) if (scheme == QLatin1String("assets"))

View File

@ -1529,7 +1529,7 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas
Q_ASSERT(QNtlmPhase3BlockBase::Size == sizeof(QNtlmPhase3BlockBase)); Q_ASSERT(QNtlmPhase3BlockBase::Size == sizeof(QNtlmPhase3BlockBase));
// for kerberos style user@domain logins, NTLM domain string should be left empty // for kerberos style user@domain logins, NTLM domain string should be left empty
if (ctx->userDomain.isEmpty() && !ctx->extractedUser.contains(QLatin1Char('@'))) { if (ctx->userDomain.isEmpty() && !ctx->extractedUser.contains(u'@')) {
offset = qEncodeNtlmString(pb.domain, offset, ch.targetNameStr, unicode); offset = qEncodeNtlmString(pb.domain, offset, ch.targetNameStr, unicode);
pb.domainStr = ch.targetNameStr; pb.domainStr = ch.targetNameStr;
} else { } else {

View File

@ -137,7 +137,7 @@ void QHostAddressPrivate::setAddress(const Q_IPV6ADDR &a_)
static bool parseIp6(const QString &address, QIPAddressUtils::IPv6Address &addr, QString *scopeId) static bool parseIp6(const QString &address, QIPAddressUtils::IPv6Address &addr, QString *scopeId)
{ {
QStringView tmp(address); QStringView tmp(address);
int scopeIdPos = tmp.lastIndexOf(QLatin1Char('%')); qsizetype scopeIdPos = tmp.lastIndexOf(u'%');
if (scopeIdPos != -1) { if (scopeIdPos != -1) {
*scopeId = tmp.mid(scopeIdPos + 1).toString(); *scopeId = tmp.mid(scopeIdPos + 1).toString();
tmp.chop(tmp.size() - scopeIdPos); tmp.chop(tmp.size() - scopeIdPos);
@ -155,7 +155,7 @@ bool QHostAddressPrivate::parse(const QString &ipString)
return false; return false;
// All IPv6 addresses contain a ':', and may contain a '.'. // All IPv6 addresses contain a ':', and may contain a '.'.
if (a.contains(QLatin1Char(':'))) { if (a.contains(u':')) {
quint8 maybeIp6[16]; quint8 maybeIp6[16];
if (parseIp6(a, maybeIp6, &scopeId)) { if (parseIp6(a, maybeIp6, &scopeId)) {
setAddress(maybeIp6); setAddress(maybeIp6);
@ -738,7 +738,7 @@ QString QHostAddress::toString() const
} else if (d->protocol == QHostAddress::IPv6Protocol) { } else if (d->protocol == QHostAddress::IPv6Protocol) {
QIPAddressUtils::toString(s, d->a6.c); QIPAddressUtils::toString(s, d->a6.c);
if (!d->scopeId.isEmpty()) if (!d->scopeId.isEmpty())
s.append(QLatin1Char('%') + d->scopeId); s.append(u'%' + d->scopeId);
} }
return s; return s;
} }
@ -1043,17 +1043,17 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
if (subnet.isEmpty()) if (subnet.isEmpty())
return invalid; return invalid;
int slash = subnet.indexOf(QLatin1Char('/')); qsizetype slash = subnet.indexOf(u'/');
QStringView netStr(subnet); QStringView netStr(subnet);
if (slash != -1) if (slash != -1)
netStr.truncate(slash); netStr.truncate(slash);
int netmask = -1; int netmask = -1;
bool isIpv6 = netStr.contains(QLatin1Char(':')); bool isIpv6 = netStr.contains(u':');
if (slash != -1) { if (slash != -1) {
// is the netmask given in IP-form or in bit-count form? // is the netmask given in IP-form or in bit-count form?
if (!isIpv6 && subnet.indexOf(QLatin1Char('.'), slash + 1) != -1) { if (!isIpv6 && subnet.indexOf(u'.', slash + 1) != -1) {
// IP-style, convert it to bit-count form // IP-style, convert it to bit-count form
QHostAddress mask; QHostAddress mask;
QNetmask parser; QNetmask parser;
@ -1089,7 +1089,7 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
return invalid; // invalid netmask return invalid; // invalid netmask
// parse the address manually // parse the address manually
auto parts = netStr.split(QLatin1Char('.')); auto parts = netStr.split(u'.');
if (parts.isEmpty() || parts.count() > 4) if (parts.isEmpty() || parts.count() > 4)
return invalid; // invalid IPv4 address return invalid; // invalid IPv4 address

View File

@ -145,7 +145,7 @@ QString QNetworkInterfacePrivate::makeHwAddress(int len, uchar *data)
QChar *out = result.data(); QChar *out = result.data();
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
if (i) if (i)
*out++ = QLatin1Char(':'); *out++ = u':';
*out++ = QLatin1Char(QtMiscUtils::toHexUpper(data[i] / 16)); *out++ = QLatin1Char(QtMiscUtils::toHexUpper(data[i] / 16));
*out++ = QLatin1Char(QtMiscUtils::toHexUpper(data[i] % 16)); *out++ = QLatin1Char(QtMiscUtils::toHexUpper(data[i] % 16));
} }

View File

@ -1592,7 +1592,7 @@ QDebug operator<<(QDebug debug, const QNetworkProxy &proxy)
scaps << QStringLiteral("SctpTunnel"); scaps << QStringLiteral("SctpTunnel");
if (caps & QNetworkProxy::SctpListeningCapability) if (caps & QNetworkProxy::SctpListeningCapability)
scaps << QStringLiteral("SctpListen"); scaps << QStringLiteral("SctpListen");
debug << '[' << scaps.join(QLatin1Char(' ')) << ']'; debug << '[' << scaps.join(u' ') << ']';
return debug; return debug;
} }

View File

@ -83,7 +83,7 @@ static bool isHostExcluded(CFDictionaryRef dict, const QString &host)
if (host.isEmpty()) if (host.isEmpty())
return true; return true;
bool isSimple = !host.contains(QLatin1Char('.')) && !host.contains(QLatin1Char(':')); bool isSimple = !host.contains(u'.') && !host.contains(u':');
CFNumberRef excludeSimples; CFNumberRef excludeSimples;
if (isSimple && if (isSimple &&
(excludeSimples = (CFNumberRef)CFDictionaryGetValue(dict, kSCPropNetProxiesExcludeSimpleHostnames))) { (excludeSimples = (CFNumberRef)CFDictionaryGetValue(dict, kSCPropNetProxiesExcludeSimpleHostnames))) {

View File

@ -82,11 +82,11 @@ static bool currentProcessIsService()
static QStringList splitSpaceSemicolon(const QString &source) static QStringList splitSpaceSemicolon(const QString &source)
{ {
QStringList list; QStringList list;
int start = 0; qsizetype start = 0;
int end; qsizetype end;
while (true) { while (true) {
int space = source.indexOf(QLatin1Char(' '), start); qsizetype space = source.indexOf(u' ', start);
int semicolon = source.indexOf(QLatin1Char(';'), start); qsizetype semicolon = source.indexOf(u';', start);
end = space; end = space;
if (semicolon != -1 && (end == -1 || semicolon < end)) if (semicolon != -1 && (end == -1 || semicolon < end))
end = semicolon; end = semicolon;
@ -108,7 +108,7 @@ static bool isBypassed(const QString &host, const QStringList &bypassList)
if (host.isEmpty()) if (host.isEmpty())
return false; return false;
bool isSimple = !host.contains(QLatin1Char('.')) && !host.contains(QLatin1Char(':')); bool isSimple = !host.contains(u'.') && !host.contains(u':');
QHostAddress ipAddress; QHostAddress ipAddress;
bool isIpAddress = ipAddress.setAddress(host); bool isIpAddress = ipAddress.setAddress(host);
@ -219,12 +219,12 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
&& query.queryType() != QNetworkProxyQuery::TcpServer && query.queryType() != QNetworkProxyQuery::TcpServer
&& query.queryType() != QNetworkProxyQuery::SctpServer; && query.queryType() != QNetworkProxyQuery::SctpServer;
for (const QString &entry : proxyList) { for (const QString &entry : proxyList) {
int server = 0; qsizetype server = 0;
QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy; QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy;
quint16 port = 8080; quint16 port = 8080;
int pos = entry.indexOf(QLatin1Char('=')); qsizetype pos = entry.indexOf(u'=');
QStringView scheme; QStringView scheme;
QStringView protocolTag; QStringView protocolTag;
if (pos != -1) { if (pos != -1) {
@ -253,7 +253,7 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
} }
} }
pos = entry.indexOf(QLatin1Char(':'), server); pos = entry.indexOf(u':', server);
if (pos != -1) { if (pos != -1) {
bool ok; bool ok;
uint value = QStringView{entry}.mid(pos + 1).toUInt(&ok); uint value = QStringView{entry}.mid(pos + 1).toUInt(&ok);

View File

@ -974,7 +974,7 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo)
if (i != 0) s += QLatin1String(", "); if (i != 0) s += QLatin1String(", ");
s += addresses.at(i).toString(); s += addresses.at(i).toString();
} }
s += QLatin1Char('}'); s += u'}';
qDebug("QAbstractSocketPrivate::_q_startConnecting(hostInfo == %s)", s.toLatin1().constData()); qDebug("QAbstractSocketPrivate::_q_startConnecting(hostInfo == %s)", s.toLatin1().constData());
#endif #endif

View File

@ -84,11 +84,11 @@ void QLocalServerPrivate::init()
bool QLocalServerPrivate::removeServer(const QString &name) bool QLocalServerPrivate::removeServer(const QString &name)
{ {
QString fileName; QString fileName;
if (name.startsWith(QLatin1Char('/'))) { if (name.startsWith(u'/')) {
fileName = name; fileName = name;
} else { } else {
fileName = QDir::cleanPath(QDir::tempPath()); fileName = QDir::cleanPath(QDir::tempPath());
fileName += QLatin1Char('/') + name; fileName += u'/' + name;
} }
if (QFile::exists(fileName)) if (QFile::exists(fileName))
return QFile::remove(fileName); return QFile::remove(fileName);
@ -105,11 +105,11 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
// determine the full server path // determine the full server path
if (options.testFlag(QLocalServer::AbstractNamespaceOption) if (options.testFlag(QLocalServer::AbstractNamespaceOption)
|| requestedServerName.startsWith(QLatin1Char('/'))) { || requestedServerName.startsWith(u'/')) {
fullServerName = requestedServerName; fullServerName = requestedServerName;
} else { } else {
fullServerName = QDir::cleanPath(QDir::tempPath()); fullServerName = QDir::cleanPath(QDir::tempPath());
fullServerName += QLatin1Char('/') + requestedServerName; fullServerName += u'/' + requestedServerName;
} }
serverName = requestedServerName; serverName = requestedServerName;

View File

@ -68,11 +68,11 @@ static QString pathNameForConnection(const QString &connectingName,
QLocalSocket::SocketOptions options) QLocalSocket::SocketOptions options)
{ {
if (options.testFlag(QLocalSocket::AbstractNamespaceOption) if (options.testFlag(QLocalSocket::AbstractNamespaceOption)
|| connectingName.startsWith(QLatin1Char('/'))) { || connectingName.startsWith(u'/')) {
return connectingName; return connectingName;
} }
return QDir::tempPath() + QLatin1Char('/') + connectingName; return QDir::tempPath() + u'/' + connectingName;
} }
static QLocalSocket::SocketOptions optionsForPlatform(QLocalSocket::SocketOptions srcOptions) static QLocalSocket::SocketOptions optionsForPlatform(QLocalSocket::SocketOptions srcOptions)
@ -446,7 +446,7 @@ bool QLocalSocketPrivate::parseSockaddr(const struct ::sockaddr_un &addr,
fullServerName = name; fullServerName = name;
serverName = abstractNamespace serverName = abstractNamespace
? name ? name
: fullServerName.mid(fullServerName.lastIndexOf(QLatin1Char('/')) + 1); : fullServerName.mid(fullServerName.lastIndexOf(u'/') + 1);
if (serverName.isEmpty()) if (serverName.isEmpty())
serverName = fullServerName; serverName = fullServerName;
} }

View File

@ -124,9 +124,9 @@ static QString dump(const QByteArray &buf)
{ {
QString data; QString data;
for (int i = 0; i < qMin<int>(MAX_DATA_DUMP, buf.size()); ++i) { for (int i = 0; i < qMin<int>(MAX_DATA_DUMP, buf.size()); ++i) {
if (i) data += QLatin1Char(' '); if (i) data += u' ';
uint val = (unsigned char)buf.at(i); uint val = (unsigned char)buf.at(i);
// data += QString("0x%1").arg(val, 3, 16, QLatin1Char('0')); // data += QString("0x%1").arg(val, 3, 16, u'0');
data += QString::number(val); data += QString::number(val);
} }
if (buf.size() > MAX_DATA_DUMP) if (buf.size() > MAX_DATA_DUMP)

View File

@ -658,7 +658,7 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
QString sourcePath = QDir::fromNativeSeparators(path); QString sourcePath = QDir::fromNativeSeparators(path);
// Find the path without the filename // Find the path without the filename
QString pathPrefix = sourcePath.left(sourcePath.lastIndexOf(QLatin1Char('/'))); QString pathPrefix = sourcePath.left(sourcePath.lastIndexOf(u'/'));
// Check if the path contains any special chars // Check if the path contains any special chars
int pos = -1; int pos = -1;
@ -677,7 +677,7 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
if (pos != -1) { if (pos != -1) {
// there was a special char in the path so cut of the part containing that char. // there was a special char in the path so cut of the part containing that char.
pathPrefix = pathPrefix.left(pos); pathPrefix = pathPrefix.left(pos);
const int lastIndexOfSlash = pathPrefix.lastIndexOf(QLatin1Char('/')); const qsizetype lastIndexOfSlash = pathPrefix.lastIndexOf(u'/');
if (lastIndexOfSlash != -1) if (lastIndexOfSlash != -1)
pathPrefix = pathPrefix.left(lastIndexOfSlash); pathPrefix = pathPrefix.left(lastIndexOfSlash);
else else

View File

@ -634,7 +634,7 @@ void QSslConfiguration::setCiphers(const QString &ciphers)
{ {
auto *p = d.data(); auto *p = d.data();
p->ciphers.clear(); p->ciphers.clear();
const auto cipherNames = ciphers.split(QLatin1Char(':'), Qt::SkipEmptyParts); const auto cipherNames = ciphers.split(u':', Qt::SkipEmptyParts);
for (const QString &cipherName : cipherNames) { for (const QString &cipherName : cipherNames) {
QSslCipher cipher(cipherName); QSslCipher cipher(cipherName);
if (!cipher.isNull()) if (!cipher.isNull())

View File

@ -3055,14 +3055,14 @@ bool QSslSocketPrivate::isMatchingHostname(const QSslCertificate &cert, const QS
*/ */
bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hostname) bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hostname)
{ {
int wildcard = cn.indexOf(QLatin1Char('*')); qsizetype wildcard = cn.indexOf(u'*');
// Check this is a wildcard cert, if not then just compare the strings // Check this is a wildcard cert, if not then just compare the strings
if (wildcard < 0) if (wildcard < 0)
return QLatin1String(QUrl::toAce(cn)) == hostname; return QLatin1String(QUrl::toAce(cn)) == hostname;
int firstCnDot = cn.indexOf(QLatin1Char('.')); qsizetype firstCnDot = cn.indexOf(u'.');
int secondCnDot = cn.indexOf(QLatin1Char('.'), firstCnDot+1); qsizetype secondCnDot = cn.indexOf(u'.', firstCnDot+1);
// Check at least 3 components // Check at least 3 components
if ((-1 == secondCnDot) || (secondCnDot+1 >= cn.length())) if ((-1 == secondCnDot) || (secondCnDot+1 >= cn.length()))
@ -3073,7 +3073,7 @@ bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hos
return false; return false;
// Check only one star // Check only one star
if (cn.lastIndexOf(QLatin1Char('*')) != wildcard) if (cn.lastIndexOf(u'*') != wildcard)
return false; return false;
// Reject wildcard character embedded within the A-labels or U-labels of an internationalized // Reject wildcard character embedded within the A-labels or U-labels of an internationalized
@ -3086,7 +3086,7 @@ bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hos
return false; return false;
// Check characters following first . match // Check characters following first . match
int hnDot = hostname.indexOf(QLatin1Char('.')); qsizetype hnDot = hostname.indexOf(u'.');
if (QStringView{hostname}.mid(hnDot + 1) != QStringView{cn}.mid(firstCnDot + 1) if (QStringView{hostname}.mid(hnDot + 1) != QStringView{cn}.mid(firstCnDot + 1)
&& QStringView{hostname}.mid(hnDot + 1) != QLatin1String(QUrl::toAce(cn.mid(firstCnDot + 1)))) { && QStringView{hostname}.mid(hnDot + 1) != QLatin1String(QUrl::toAce(cn.mid(firstCnDot + 1)))) {
return false; return false;

View File

@ -806,7 +806,7 @@ QSslCipher QTlsBackend::createCiphersuite(const QString &descriptionOneLine, int
{ {
QSslCipher ciph; QSslCipher ciph;
const auto descriptionList = QStringView{descriptionOneLine}.split(QLatin1Char(' '), Qt::SkipEmptyParts); const auto descriptionList = QStringView{descriptionOneLine}.split(u' ', Qt::SkipEmptyParts);
if (descriptionList.size() > 5) { if (descriptionList.size() > 5) {
ciph.d->isNull = false; ciph.d->isNull = false;
ciph.d->name = descriptionList.at(0).toString(); ciph.d->name = descriptionList.at(0).toString();
@ -868,7 +868,7 @@ QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslPro
ciph.d->protocol = protocol; ciph.d->protocol = protocol;
ciph.d->protocolString = protocolString; ciph.d->protocolString = protocolString;
const auto bits = QStringView{ciph.d->name}.split(QLatin1Char('-')); const auto bits = QStringView{ciph.d->name}.split(u'-');
if (bits.size() >= 2) { if (bits.size() >= 2) {
if (bits.size() == 2 || bits.size() == 3) if (bits.size() == 2 || bits.size() == 3)
ciph.d->keyExchangeMethod = QLatin1String("RSA"); ciph.d->keyExchangeMethod = QLatin1String("RSA");

View File

@ -583,8 +583,8 @@ struct LibGreaterThan
typedef bool result_type; typedef bool result_type;
result_type operator()(QStringView lhs, QStringView rhs) const result_type operator()(QStringView lhs, QStringView rhs) const
{ {
const auto lhsparts = lhs.split(QLatin1Char('.')); const auto lhsparts = lhs.split(u'.');
const auto rhsparts = rhs.split(QLatin1Char('.')); const auto rhsparts = rhs.split(u'.');
Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1); Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
// note: checking rhs < lhs, the same as lhs > rhs // note: checking rhs < lhs, the same as lhs > rhs
@ -615,8 +615,7 @@ static QStringList libraryPathList()
{ {
QStringList paths; QStringList paths;
# ifdef Q_OS_DARWIN # ifdef Q_OS_DARWIN
paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH")) paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
.split(QLatin1Char(':'), Qt::SkipEmptyParts);
// search in .app/Contents/Frameworks // search in .app/Contents/Frameworks
UInt32 packageType; UInt32 packageType;
@ -627,8 +626,7 @@ static QStringList libraryPathList()
paths << bundleUrl.resolved(frameworksUrl).path(); paths << bundleUrl.resolved(frameworksUrl).path();
} }
# else # else
paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")) paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
.split(QLatin1Char(':'), Qt::SkipEmptyParts);
# endif # endif
paths << QLatin1String("/lib") << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib"); paths << QLatin1String("/lib") << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib");
paths << QLatin1String("/lib64") << QLatin1String("/usr/lib64") << QLatin1String("/usr/local/lib64"); paths << QLatin1String("/lib64") << QLatin1String("/usr/lib64") << QLatin1String("/usr/local/lib64");
@ -659,7 +657,7 @@ static QStringList findAllLibs(QLatin1String filter)
std::sort(entryList.begin(), entryList.end(), LibGreaterThan()); std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
for (const QString &entry : qAsConst(entryList)) for (const QString &entry : qAsConst(entryList))
found << path + QLatin1Char('/') + entry; found << path + u'/' + entry;
} }
return found; return found;