QtNetwork: use _L1 for for creating Latin-1 string literals

Task-number: QTBUG-98434
Change-Id: Ic235b92377203f7a1429ae7fd784c4a1fa893e9f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Sona Kurazyan 2022-04-12 15:03:54 +02:00
parent f2637e1a77
commit 46d6cc47cf
53 changed files with 514 additions and 441 deletions

View File

@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN_TAGGED(Http2::Settings, Http2__Settings) QT_IMPL_METATYPE_EXTERN_TAGGED(Http2::Settings, Http2__Settings)
Q_LOGGING_CATEGORY(QT_HTTP2, "qt.network.http2") Q_LOGGING_CATEGORY(QT_HTTP2, "qt.network.http2")
@ -130,7 +132,7 @@ void qt_error(quint32 errorCode, QNetworkReply::NetworkError &error,
{ {
if (errorCode > quint32(HTTP_1_1_REQUIRED)) { if (errorCode > quint32(HTTP_1_1_REQUIRED)) {
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("RST_STREAM with unknown error code (%1)"); errorMessage = "RST_STREAM with unknown error code (%1)"_L1;
errorMessage = errorMessage.arg(errorCode); errorMessage = errorMessage.arg(errorCode);
return; return;
} }
@ -144,61 +146,61 @@ void qt_error(quint32 errorCode, QNetworkReply::NetworkError &error,
break; break;
case PROTOCOL_ERROR: case PROTOCOL_ERROR:
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("HTTP/2 protocol error"); errorMessage = "HTTP/2 protocol error"_L1;
break; break;
case INTERNAL_ERROR: case INTERNAL_ERROR:
error = QNetworkReply::InternalServerError; error = QNetworkReply::InternalServerError;
errorMessage = QLatin1String("Internal server error"); errorMessage = "Internal server error"_L1;
break; break;
case FLOW_CONTROL_ERROR: case FLOW_CONTROL_ERROR:
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Flow control error"); errorMessage = "Flow control error"_L1;
break; break;
case SETTINGS_TIMEOUT: case SETTINGS_TIMEOUT:
error = QNetworkReply::TimeoutError; error = QNetworkReply::TimeoutError;
errorMessage = QLatin1String("SETTINGS ACK timeout error"); errorMessage = "SETTINGS ACK timeout error"_L1;
break; break;
case STREAM_CLOSED: case STREAM_CLOSED:
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server received frame(s) on a half-closed stream"); errorMessage = "Server received frame(s) on a half-closed stream"_L1;
break; break;
case FRAME_SIZE_ERROR: case FRAME_SIZE_ERROR:
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server received a frame with an invalid size"); errorMessage = "Server received a frame with an invalid size"_L1;
break; break;
case REFUSE_STREAM: case REFUSE_STREAM:
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server refused a stream"); errorMessage = "Server refused a stream"_L1;
break; break;
case CANCEL: case CANCEL:
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Stream is no longer needed"); errorMessage = "Stream is no longer needed"_L1;
break; break;
case COMPRESSION_ERROR: case COMPRESSION_ERROR:
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server is unable to maintain the " errorMessage = "Server is unable to maintain the "
"header compression context for the connection"); "header compression context for the connection"_L1;
break; break;
case CONNECT_ERROR: case CONNECT_ERROR:
// TODO: in Qt6 we'll have to add more error codes in QNetworkReply. // TODO: in Qt6 we'll have to add more error codes in QNetworkReply.
error = QNetworkReply::UnknownNetworkError; error = QNetworkReply::UnknownNetworkError;
errorMessage = QLatin1String("The connection established in response " errorMessage = "The connection established in response "
"to a CONNECT request was reset or abnormally closed"); "to a CONNECT request was reset or abnormally closed"_L1;
break; break;
case ENHANCE_YOUR_CALM: case ENHANCE_YOUR_CALM:
error = QNetworkReply::UnknownServerError; error = QNetworkReply::UnknownServerError;
errorMessage = QLatin1String("Server dislikes our behavior, excessive load detected."); errorMessage = "Server dislikes our behavior, excessive load detected."_L1;
break; break;
case INADEQUATE_SECURITY: case INADEQUATE_SECURITY:
error = QNetworkReply::ContentAccessDenied; error = QNetworkReply::ContentAccessDenied;
errorMessage = QLatin1String("The underlying transport has properties " errorMessage = "The underlying transport has properties "
"that do not meet minimum security " "that do not meet minimum security "
"requirements"); "requirements"_L1;
break; break;
case HTTP_1_1_REQUIRED: case HTTP_1_1_REQUIRED:
error = QNetworkReply::ProtocolFailure; error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server requires that HTTP/1.1 " errorMessage = "Server requires that HTTP/1.1 "
"be used instead of HTTP/2."); "be used instead of HTTP/2."_L1;
} }
} }

View File

@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static QString host_name_to_settings_key(const QString &hostName) static QString host_name_to_settings_key(const QString &hostName)
{ {
const QByteArray hostNameAsHex(hostName.toUtf8().toHex()); const QByteArray hostNameAsHex(hostName.toUtf8().toHex());
@ -136,13 +138,13 @@ QString QHstsStore::absoluteFilePath(const QString &dirName)
{ {
const QDir dir(dirName.isEmpty() ? QStandardPaths::writableLocation(QStandardPaths::CacheLocation) const QDir dir(dirName.isEmpty() ? QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
: dirName); : dirName);
return dir.absoluteFilePath(QLatin1String("hstsstore")); return dir.absoluteFilePath("hstsstore"_L1);
} }
void QHstsStore::beginHstsGroups() void QHstsStore::beginHstsGroups()
{ {
store.beginGroup(QLatin1String("StrictTransportSecurity")); store.beginGroup("StrictTransportSecurity"_L1);
store.beginGroup(QLatin1String("Policies")); store.beginGroup("Policies"_L1);
} }
void QHstsStore::endHstsGroups() void QHstsStore::endHstsGroups()

View File

@ -65,6 +65,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace namespace
{ {
@ -239,8 +241,7 @@ void QHttp2ProtocolHandler::_q_uploadDataReadyRead()
auto &stream = activeStreams[streamID]; auto &stream = activeStreams[streamID];
if (!sendDATA(stream)) { if (!sendDATA(stream)) {
finishStreamWithError(stream, QNetworkReply::UnknownNetworkError, finishStreamWithError(stream, QNetworkReply::UnknownNetworkError, "failed to send DATA"_L1);
QLatin1String("failed to send DATA"));
sendRST_STREAM(streamID, INTERNAL_ERROR); sendRST_STREAM(streamID, INTERNAL_ERROR);
markAsReset(streamID); markAsReset(streamID);
deleteActiveStream(streamID); deleteActiveStream(streamID);
@ -354,8 +355,7 @@ bool QHttp2ProtocolHandler::sendRequest()
for (auto it = requests.begin(), endIt = requests.end(); it != endIt;) { for (auto it = requests.begin(), endIt = requests.end(); it != endIt;) {
const auto &pair = *it; const auto &pair = *it;
const QString scheme(pair.first.url().scheme()); const QString scheme(pair.first.url().scheme());
if (scheme == QLatin1String("preconnect-http") if (scheme == "preconnect-http"_L1 || scheme == "preconnect-https"_L1) {
|| scheme == QLatin1String("preconnect-https")) {
m_connection->preConnectFinished(); m_connection->preConnectFinished();
emit pair.second->finished(); emit pair.second->finished();
it = requests.erase(it); it = requests.erase(it);
@ -410,14 +410,14 @@ bool QHttp2ProtocolHandler::sendRequest()
Stream &newStream = activeStreams[newStreamID]; Stream &newStream = activeStreams[newStreamID];
if (!sendHEADERS(newStream)) { if (!sendHEADERS(newStream)) {
finishStreamWithError(newStream, QNetworkReply::UnknownNetworkError, finishStreamWithError(newStream, QNetworkReply::UnknownNetworkError,
QLatin1String("failed to send HEADERS frame(s)")); "failed to send HEADERS frame(s)"_L1);
deleteActiveStream(newStreamID); deleteActiveStream(newStreamID);
continue; continue;
} }
if (newStream.data() && !sendDATA(newStream)) { if (newStream.data() && !sendDATA(newStream)) {
finishStreamWithError(newStream, QNetworkReply::UnknownNetworkError, finishStreamWithError(newStream, QNetworkReply::UnknownNetworkError,
QLatin1String("failed to send DATA frame(s)")); "failed to send DATA frame(s)"_L1);
sendRST_STREAM(newStreamID, INTERNAL_ERROR); sendRST_STREAM(newStreamID, INTERNAL_ERROR);
markAsReset(newStreamID); markAsReset(newStreamID);
deleteActiveStream(newStreamID); deleteActiveStream(newStreamID);
@ -616,8 +616,7 @@ void QHttp2ProtocolHandler::handleDATA()
auto &stream = activeStreams[streamID]; auto &stream = activeStreams[streamID];
if (qint32(inboundFrame.payloadSize()) > stream.recvWindow) { if (qint32(inboundFrame.payloadSize()) > stream.recvWindow) {
finishStreamWithError(stream, QNetworkReply::ProtocolFailure, finishStreamWithError(stream, QNetworkReply::ProtocolFailure, "flow control error"_L1);
QLatin1String("flow control error"));
sendRST_STREAM(streamID, FLOW_CONTROL_ERROR); sendRST_STREAM(streamID, FLOW_CONTROL_ERROR);
markAsReset(streamID); markAsReset(streamID);
deleteActiveStream(streamID); deleteActiveStream(streamID);
@ -891,7 +890,7 @@ void QHttp2ProtocolHandler::handleGOAWAY()
// successful completion. // successful completion.
if (errorCode == HTTP2_NO_ERROR) { if (errorCode == HTTP2_NO_ERROR) {
error = QNetworkReply::ContentReSendError; error = QNetworkReply::ContentReSendError;
message = QLatin1String("Server stopped accepting new streams before this stream was established"); message = "Server stopped accepting new streams before this stream was established"_L1;
} }
for (quint32 id = lastStreamID; id < nextID; id += 2) { for (quint32 id = lastStreamID; id < nextID; id += 2) {
@ -931,7 +930,7 @@ void QHttp2ProtocolHandler::handleWINDOW_UPDATE()
auto &stream = activeStreams[streamID]; auto &stream = activeStreams[streamID];
if (!valid || sum_will_overflow(stream.sendWindow, delta)) { if (!valid || sum_will_overflow(stream.sendWindow, delta)) {
finishStreamWithError(stream, QNetworkReply::ProtocolFailure, finishStreamWithError(stream, QNetworkReply::ProtocolFailure,
QLatin1String("invalid WINDOW_UPDATE delta")); "invalid WINDOW_UPDATE delta"_L1);
sendRST_STREAM(streamID, PROTOCOL_ERROR); sendRST_STREAM(streamID, PROTOCOL_ERROR);
markAsReset(streamID); markAsReset(streamID);
deleteActiveStream(streamID); deleteActiveStream(streamID);
@ -986,7 +985,7 @@ void QHttp2ProtocolHandler::handleContinuedHEADERS()
// (these streams are in halfClosedLocal or open state) or // (these streams are in halfClosedLocal or open state) or
// remote-reserved streams from a server's PUSH_PROMISE. // remote-reserved streams from a server's PUSH_PROMISE.
finishStreamWithError(stream, QNetworkReply::ProtocolFailure, finishStreamWithError(stream, QNetworkReply::ProtocolFailure,
QLatin1String("HEADERS on invalid stream")); "HEADERS on invalid stream"_L1);
sendRST_STREAM(streamID, CANCEL); sendRST_STREAM(streamID, CANCEL);
markAsReset(streamID); markAsReset(streamID);
deleteActiveStream(streamID); deleteActiveStream(streamID);
@ -1077,7 +1076,7 @@ bool QHttp2ProtocolHandler::acceptSetting(Http2::Settings identifier, quint32 ne
for (auto id : brokenStreams) { for (auto id : brokenStreams) {
auto &stream = activeStreams[id]; auto &stream = activeStreams[id];
finishStreamWithError(stream, QNetworkReply::ProtocolFailure, finishStreamWithError(stream, QNetworkReply::ProtocolFailure,
QLatin1String("SETTINGS window overflow")); "SETTINGS window overflow"_L1);
sendRST_STREAM(id, PROTOCOL_ERROR); sendRST_STREAM(id, PROTOCOL_ERROR);
markAsReset(id); markAsReset(id);
deleteActiveStream(id); deleteActiveStream(id);
@ -1491,7 +1490,7 @@ void QHttp2ProtocolHandler::resumeSuspendedStreams()
Stream &stream = activeStreams[streamID]; Stream &stream = activeStreams[streamID];
if (!sendDATA(stream)) { if (!sendDATA(stream)) {
finishStreamWithError(stream, QNetworkReply::UnknownNetworkError, finishStreamWithError(stream, QNetworkReply::UnknownNetworkError,
QLatin1String("failed to send DATA")); "failed to send DATA"_L1);
sendRST_STREAM(streamID, INTERNAL_ERROR); sendRST_STREAM(streamID, INTERNAL_ERROR);
markAsReset(streamID); markAsReset(streamID);
deleteActiveStream(streamID); deleteActiveStream(streamID);

View File

@ -66,6 +66,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
const int QHttpNetworkConnectionPrivate::defaultHttpChannelCount = 6; const int QHttpNetworkConnectionPrivate::defaultHttpChannelCount = 6;
// The pipeline length. So there will be 4 requests in flight. // The pipeline length. So there will be 4 requests in flight.
@ -318,12 +320,12 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair)
if (value.isEmpty()) { if (value.isEmpty()) {
QString systemLocale = QLocale::system().name().replace(QChar::fromLatin1('_'),QChar::fromLatin1('-')); QString systemLocale = QLocale::system().name().replace(QChar::fromLatin1('_'),QChar::fromLatin1('-'));
QString acceptLanguage; QString acceptLanguage;
if (systemLocale == QLatin1String("C")) if (systemLocale == "C"_L1)
acceptLanguage = QString::fromLatin1("en,*"); acceptLanguage = QString::fromLatin1("en,*");
else if (systemLocale.startsWith(QLatin1String("en-"))) else if (systemLocale.startsWith("en-"_L1))
acceptLanguage = systemLocale + QLatin1String(",*"); acceptLanguage = systemLocale + ",*"_L1;
else else
acceptLanguage = systemLocale + QLatin1String(",en,*"); acceptLanguage = systemLocale + ",en,*"_L1;
request.setHeaderField("Accept-Language", std::move(acceptLanguage).toLatin1()); request.setHeaderField("Accept-Language", std::move(acceptLanguage).toLatin1());
} }
@ -567,7 +569,7 @@ QHttpNetworkConnectionPrivate::parseRedirectResponse(QHttpNetworkReply *reply)
// Check redirect url protocol // Check redirect url protocol
const QUrl priorUrl(reply->request().url()); const QUrl priorUrl(reply->request().url());
if (redirectUrl.scheme() == QLatin1String("http") || redirectUrl.scheme() == QLatin1String("https")) { if (redirectUrl.scheme() == "http"_L1 || redirectUrl.scheme() == "https"_L1) {
switch (reply->request().redirectPolicy()) { switch (reply->request().redirectPolicy()) {
case QNetworkRequest::NoLessSafeRedirectPolicy: case QNetworkRequest::NoLessSafeRedirectPolicy:
// Here we could handle https->http redirects as InsecureProtocolError. // Here we could handle https->http redirects as InsecureProtocolError.

View File

@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QHttpNetworkReply::QHttpNetworkReply(const QUrl &url, QObject *parent) QHttpNetworkReply::QHttpNetworkReply(const QUrl &url, QObject *parent)
: QObject(*new QHttpNetworkReplyPrivate(url), parent) : QObject(*new QHttpNetworkReplyPrivate(url), parent)
{ {
@ -352,8 +354,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
{ {
QString scheme = newUrl.scheme(); QString scheme = newUrl.scheme();
if (scheme == QLatin1String("preconnect-http") if (scheme == "preconnect-http"_L1 || scheme == "preconnect-https"_L1)
|| scheme == QLatin1String("preconnect-https"))
// make sure we do not close the socket after preconnecting // make sure we do not close the socket after preconnecting
connectionCloseEnabled = false; connectionCloseEnabled = false;
} }

View File

@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QHttpProtocolHandler::QHttpProtocolHandler(QHttpNetworkConnectionChannel *channel) QHttpProtocolHandler::QHttpProtocolHandler(QHttpNetworkConnectionChannel *channel)
: QAbstractProtocolHandler(channel) : QAbstractProtocolHandler(channel)
{ {
@ -273,8 +275,7 @@ bool QHttpProtocolHandler::sendRequest()
return false; return false;
} }
QString scheme = m_channel->request.url().scheme(); QString scheme = m_channel->request.url().scheme();
if (scheme == QLatin1String("preconnect-http") if (scheme == "preconnect-http"_L1 || scheme == "preconnect-https"_L1) {
|| scheme == QLatin1String("preconnect-https")) {
m_channel->state = QHttpNetworkConnectionChannel::IdleState; m_channel->state = QHttpNetworkConnectionChannel::IdleState;
m_reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState; m_reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState;
m_channel->allDone(); m_channel->allDone();

View File

@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url) static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url)
{ {
QNetworkReply::NetworkError code; QNetworkReply::NetworkError code;
@ -128,14 +130,12 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy, const QString &p
QString result; QString result;
QUrl copy = url; QUrl copy = url;
QString scheme = copy.scheme(); QString scheme = copy.scheme();
bool isEncrypted = scheme == QLatin1String("https") bool isEncrypted = scheme == "https"_L1 || scheme == "preconnect-https"_L1;
|| scheme == QLatin1String("preconnect-https");
copy.setPort(copy.port(isEncrypted ? 443 : 80)); copy.setPort(copy.port(isEncrypted ? 443 : 80));
if (scheme == QLatin1String("preconnect-http")) { if (scheme == "preconnect-http"_L1)
copy.setScheme(QLatin1String("http")); copy.setScheme("http"_L1);
} else if (scheme == QLatin1String("preconnect-https")) { else if (scheme == "preconnect-https"_L1)
copy.setScheme(QLatin1String("https")); copy.setScheme("https"_L1);
}
result = copy.toString(QUrl::RemoveUserInfo | QUrl::RemovePath | result = copy.toString(QUrl::RemoveUserInfo | QUrl::RemovePath |
QUrl::RemoveQuery | QUrl::RemoveFragment | QUrl::FullyEncoded); QUrl::RemoveQuery | QUrl::RemoveFragment | QUrl::FullyEncoded);
@ -145,12 +145,12 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy, const QString &p
switch (proxy->type()) { switch (proxy->type()) {
case QNetworkProxy::Socks5Proxy: case QNetworkProxy::Socks5Proxy:
key.setScheme(QLatin1String("proxy-socks5")); key.setScheme("proxy-socks5"_L1);
break; break;
case QNetworkProxy::HttpProxy: case QNetworkProxy::HttpProxy:
case QNetworkProxy::HttpCachingProxy: case QNetworkProxy::HttpCachingProxy:
key.setScheme(QLatin1String("proxy-http")); key.setScheme("proxy-http"_L1);
break; break;
default: default:

View File

@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
class QNetworkAuthenticationCache : private QList<QNetworkAuthenticationCredential>, class QNetworkAuthenticationCache : private QList<QNetworkAuthenticationCredential>,
public QNetworkAccessCache::CacheableObject public QNetworkAccessCache::CacheableObject
{ {
@ -105,16 +107,16 @@ static QByteArray proxyAuthenticationKey(const QNetworkProxy &proxy, const QStri
switch (proxy.type()) { switch (proxy.type()) {
case QNetworkProxy::Socks5Proxy: case QNetworkProxy::Socks5Proxy:
key.setScheme(QLatin1String("proxy-socks5")); key.setScheme("proxy-socks5"_L1);
break; break;
case QNetworkProxy::HttpProxy: case QNetworkProxy::HttpProxy:
case QNetworkProxy::HttpCachingProxy: case QNetworkProxy::HttpCachingProxy:
key.setScheme(QLatin1String("proxy-http")); key.setScheme("proxy-http"_L1);
break; break;
case QNetworkProxy::FtpCachingProxy: case QNetworkProxy::FtpCachingProxy:
key.setScheme(QLatin1String("proxy-ftp")); key.setScheme("proxy-ftp"_L1);
break; break;
case QNetworkProxy::DefaultProxy: case QNetworkProxy::DefaultProxy:

View File

@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
#ifdef QT_BUILD_INTERNAL #ifdef QT_BUILD_INTERNAL
enum { enum {
@ -74,7 +76,7 @@ QNetworkAccessDebugPipeBackendFactory::create(QNetworkAccessManager::Operation o
} }
QUrl url = request.url(); QUrl url = request.url();
if (url.scheme() == QLatin1String("debugpipe")) if (url.scheme() == "debugpipe"_L1)
return new QNetworkAccessDebugPipeBackend; return new QNetworkAccessDebugPipeBackend;
return nullptr; return nullptr;
} }
@ -109,7 +111,7 @@ void QNetworkAccessDebugPipeBackend::open()
// socket bytes written -> we can push more from upstream to socket // socket bytes written -> we can push more from upstream to socket
connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64)));
bareProtocol = QUrlQuery(url()).queryItemValue(QLatin1String("bare")) == QLatin1String("1"); bareProtocol = QUrlQuery(url()).queryItemValue("bare"_L1) == "1"_L1;
if (operation() == QNetworkAccessManager::PutOperation) { if (operation() == QNetworkAccessManager::PutOperation) {
createUploadByteDevice(); createUploadByteDevice();

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QStringList QNetworkAccessFileBackendFactory::supportedSchemes() const QStringList QNetworkAccessFileBackendFactory::supportedSchemes() const
{ {
QStringList schemes; QStringList schemes;
@ -74,9 +76,9 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
} }
QUrl url = request.url(); QUrl url = request.url();
if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 if (url.scheme().compare("qrc"_L1, Qt::CaseInsensitive) == 0
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
|| url.scheme().compare(QLatin1String("assets"), Qt::CaseInsensitive) == 0 || url.scheme().compare("assets"_L1, Qt::CaseInsensitive) == 0
#endif #endif
|| url.isLocalFile()) { || url.isLocalFile()) {
return new QNetworkAccessFileBackend; return new QNetworkAccessFileBackend;
@ -112,7 +114,7 @@ void QNetworkAccessFileBackend::open()
{ {
QUrl url = this->url(); QUrl url = this->url();
if (url.host() == QLatin1String("localhost")) if (url.host() == "localhost"_L1)
url.setHost(QString()); url.setHost(QString());
#if !defined(Q_OS_WIN) #if !defined(Q_OS_WIN)
// do not allow UNC paths on Unix // do not allow UNC paths on Unix
@ -125,17 +127,17 @@ void QNetworkAccessFileBackend::open()
} }
#endif // !defined(Q_OS_WIN) #endif // !defined(Q_OS_WIN)
if (url.path().isEmpty()) if (url.path().isEmpty())
url.setPath(QLatin1String("/")); url.setPath("/"_L1);
setUrl(url); setUrl(url);
QString fileName = url.toLocalFile(); QString fileName = url.toLocalFile();
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
if (url.scheme() == QLatin1String("qrc")) { if (url.scheme() == "qrc"_L1) {
fileName = u':' + 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() == "assets"_L1)
fileName = QLatin1String("assets:") + url.path(); fileName = "assets:"_L1 + url.path();
else else
#endif #endif
fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery); fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery);

View File

@ -100,14 +100,15 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_APPLICATION_STATIC(QNetworkAccessFileBackendFactory, fileBackend) Q_APPLICATION_STATIC(QNetworkAccessFileBackendFactory, fileBackend)
#ifdef QT_BUILD_INTERNAL #ifdef QT_BUILD_INTERNAL
Q_GLOBAL_STATIC(QNetworkAccessDebugPipeBackendFactory, debugpipeBackend) Q_GLOBAL_STATIC(QNetworkAccessDebugPipeBackendFactory, debugpipeBackend)
#endif #endif
Q_APPLICATION_STATIC(QFactoryLoader, loader, QNetworkAccessBackendFactory_iid, Q_APPLICATION_STATIC(QFactoryLoader, loader, QNetworkAccessBackendFactory_iid, "/networkaccess"_L1)
QLatin1String("/networkaccess"))
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString& username, QString& password) bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString& username, QString& password)
@ -116,13 +117,13 @@ bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString&
SecKeychainItemRef itemRef; SecKeychainItemRef itemRef;
bool retValue = false; bool retValue = false;
SecProtocolType protocolType = kSecProtocolTypeAny; SecProtocolType protocolType = kSecProtocolTypeAny;
if (scheme.compare(QLatin1String("ftp"),Qt::CaseInsensitive)==0) { if (scheme.compare("ftp"_L1, Qt::CaseInsensitive) == 0) {
protocolType = kSecProtocolTypeFTPProxy; protocolType = kSecProtocolTypeFTPProxy;
} else if (scheme.compare(QLatin1String("http"),Qt::CaseInsensitive)==0 } else if (scheme.compare("http"_L1, Qt::CaseInsensitive) == 0
|| scheme.compare(QLatin1String("preconnect-http"),Qt::CaseInsensitive)==0) { || scheme.compare("preconnect-http"_L1, Qt::CaseInsensitive) == 0) {
protocolType = kSecProtocolTypeHTTPProxy; protocolType = kSecProtocolTypeHTTPProxy;
} else if (scheme.compare(QLatin1String("https"),Qt::CaseInsensitive)==0 } else if (scheme.compare("https"_L1,Qt::CaseInsensitive)==0
|| scheme.compare(QLatin1String("preconnect-https"),Qt::CaseInsensitive)==0) { || scheme.compare("preconnect-https"_L1, Qt::CaseInsensitive) == 0) {
protocolType = kSecProtocolTypeHTTPSProxy; protocolType = kSecProtocolTypeHTTPSProxy;
} }
QByteArray proxyHostnameUtf8(proxyHostname.toUtf8()); QByteArray proxyHostnameUtf8(proxyHostname.toUtf8());
@ -978,7 +979,7 @@ void QNetworkAccessManager::connectToHostEncrypted(const QString &hostName, quin
QUrl url; QUrl url;
url.setHost(hostName); url.setHost(hostName);
url.setPort(port); url.setPort(port);
url.setScheme(QLatin1String("preconnect-https")); url.setScheme("preconnect-https"_L1);
QNetworkRequest request(url); QNetworkRequest request(url);
if (sslConfiguration != QSslConfiguration::defaultConfiguration()) if (sslConfiguration != QSslConfiguration::defaultConfiguration())
request.setSslConfiguration(sslConfiguration); request.setSslConfiguration(sslConfiguration);
@ -1009,7 +1010,7 @@ void QNetworkAccessManager::connectToHost(const QString &hostName, quint16 port)
QUrl url; QUrl url;
url.setHost(hostName); url.setHost(hostName);
url.setPort(port); url.setPort(port);
url.setScheme(QLatin1String("preconnect-http")); url.setScheme("preconnect-http"_L1);
QNetworkRequest request(url); QNetworkRequest request(url);
get(request); get(request);
} }
@ -1164,13 +1165,13 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
|| op == QNetworkAccessManager::HeadOperation) { || op == QNetworkAccessManager::HeadOperation) {
if (isLocalFile if (isLocalFile
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
|| scheme == QLatin1String("assets") || scheme == "assets"_L1
#endif #endif
|| scheme == QLatin1String("qrc")) { || scheme == "qrc"_L1) {
return new QNetworkReplyFileImpl(this, req, op); return new QNetworkReplyFileImpl(this, req, op);
} }
if (scheme == QLatin1String("data")) if (scheme == "data"_L1)
return new QNetworkReplyDataImpl(this, req, op); return new QNetworkReplyDataImpl(this, req, op);
// A request with QNetworkRequest::AlwaysCache does not need any bearer management // A request with QNetworkRequest::AlwaysCache does not need any bearer management
@ -1212,7 +1213,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
#ifdef Q_OS_WASM #ifdef Q_OS_WASM
Q_UNUSED(isLocalFile); Q_UNUSED(isLocalFile);
// Support http, https, and relative urls // Support http, https, and relative urls
if (scheme == QLatin1String("http") || scheme == QLatin1String("https") || scheme.isEmpty()) { if (scheme == "http"_L1 || scheme == "https"_L1 || scheme.isEmpty()) {
QNetworkReplyWasmImpl *reply = new QNetworkReplyWasmImpl(this); QNetworkReplyWasmImpl *reply = new QNetworkReplyWasmImpl(this);
QNetworkReplyWasmImplPrivate *priv = reply->d_func(); QNetworkReplyWasmImplPrivate *priv = reply->d_func();
priv->manager = this; priv->manager = this;
@ -1246,7 +1247,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
// MUST NOT add one. // MUST NOT add one.
if (stsUrl.port() == 80) if (stsUrl.port() == 80)
stsUrl.setPort(443); stsUrl.setPort(443);
stsUrl.setScheme(QLatin1String("https")); stsUrl.setScheme("https"_L1);
request.setUrl(stsUrl); request.setUrl(stsUrl);
} }
#endif #endif

View File

@ -537,7 +537,7 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const
if (!isSessionCookie()) { if (!isSessionCookie()) {
result += "; expires="; result += "; expires=";
result += QLocale::c().toString(d->expirationDate.toUTC(), result += QLocale::c().toString(d->expirationDate.toUTC(),
QLatin1String("ddd, dd-MMM-yyyy hh:mm:ss 'GMT")).toLatin1(); "ddd, dd-MMM-yyyy hh:mm:ss 'GMT"_L1).toLatin1();
} }
if (!d->domain.isEmpty()) { if (!d->domain.isEmpty()) {
result += "; domain="; result += "; domain=";
@ -759,7 +759,7 @@ static QDateTime parseDateString(const QByteArray &dateString)
int ms = match.capturedView(4).toInt(); int ms = match.capturedView(4).toInt();
QStringView ampm = match.capturedView(5); QStringView ampm = match.capturedView(5);
if (h < 12 && !ampm.isEmpty()) if (h < 12 && !ampm.isEmpty())
if (ampm == QLatin1String("pm")) if (ampm == "pm"_L1)
h += 12; h += 12;
time = QTime(h, m, s, ms); time = QTime(h, m, s, ms);
#ifdef PARSEDATESTRINGDEBUG #ifdef PARSEDATESTRINGDEBUG

View File

@ -57,6 +57,8 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/*! /*!
\class QNetworkCookieJar \class QNetworkCookieJar
\since 4.4 \since 4.4
@ -148,7 +150,7 @@ void QNetworkCookieJar::setAllCookies(const QList<QNetworkCookie> &cookieList)
static inline bool isParentPath(const QString &path, const QString &reference) static inline bool isParentPath(const QString &path, const QString &reference)
{ {
if ((path.isEmpty() && reference == QLatin1String("/")) || path.startsWith(reference)) { if ((path.isEmpty() && reference == "/"_L1) || path.startsWith(reference)) {
//The cookie-path and the request-path are identical. //The cookie-path and the request-path are identical.
if (path.length() == reference.length()) if (path.length() == reference.length())
return true; return true;
@ -234,7 +236,7 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const
Q_D(const QNetworkCookieJar); Q_D(const QNetworkCookieJar);
const QDateTime now = QDateTime::currentDateTimeUtc(); const QDateTime now = QDateTime::currentDateTimeUtc();
QList<QNetworkCookie> result; QList<QNetworkCookie> result;
bool isEncrypted = url.scheme() == QLatin1String("https"); bool isEncrypted = url.scheme() == "https"_L1;
// scan our cookies for something that matches // scan our cookies for something that matches
QList<QNetworkCookie>::ConstIterator it = d->allCookies.constBegin(), QList<QNetworkCookie>::ConstIterator it = d->allCookies.constBegin(),

View File

@ -56,15 +56,17 @@
#include <memory> #include <memory>
#define CACHE_POSTFIX QLatin1String(".d") #define CACHE_POSTFIX ".d"_L1
#define PREPARED_SLASH QLatin1String("prepared/") #define PREPARED_SLASH "prepared/"_L1
#define CACHE_VERSION 8 #define CACHE_VERSION 8
#define DATA_DIR QLatin1String("data") #define DATA_DIR "data"_L1
#define MAX_COMPRESSION_SIZE (1024 * 1024 * 3) #define MAX_COMPRESSION_SIZE (1024 * 1024 * 3)
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/*! /*!
\class QNetworkDiskCache \class QNetworkDiskCache
\since 4.5 \since 4.5
@ -606,7 +608,7 @@ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url)
QString QNetworkDiskCachePrivate::tmpCacheFileName() const QString QNetworkDiskCachePrivate::tmpCacheFileName() const
{ {
//The subdirectory is presumed to be already read for use. //The subdirectory is presumed to be already read for use.
return cacheDirectory + PREPARED_SLASH + QLatin1String("XXXXXX") + CACHE_POSTFIX; return cacheDirectory + PREPARED_SLASH + "XXXXXX"_L1 + CACHE_POSTFIX;
} }
/*! /*!

View File

@ -49,6 +49,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN_TAGGED(QNetworkRequest::KnownHeaders, QNetworkRequest__KnownHeaders) QT_IMPL_METATYPE_EXTERN_TAGGED(QNetworkRequest::KnownHeaders, QNetworkRequest__KnownHeaders)
QNetworkReplyFileImplPrivate::QNetworkReplyFileImplPrivate() QNetworkReplyFileImplPrivate::QNetworkReplyFileImplPrivate()
@ -82,7 +84,7 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
d->managerPrivate = manager->d_func(); d->managerPrivate = manager->d_func();
QUrl url = req.url(); QUrl url = req.url();
if (url.host() == QLatin1String("localhost")) if (url.host() == "localhost"_L1)
url.setHost(QString()); url.setHost(QString());
#if !defined(Q_OS_WIN) #if !defined(Q_OS_WIN)
@ -98,18 +100,18 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
} }
#endif #endif
if (url.path().isEmpty()) if (url.path().isEmpty())
url.setPath(QLatin1String("/")); url.setPath("/"_L1);
setUrl(url); setUrl(url);
QString fileName = url.toLocalFile(); QString fileName = url.toLocalFile();
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
const QString scheme = url.scheme(); const QString scheme = url.scheme();
if (scheme == QLatin1String("qrc")) { if (scheme == "qrc"_L1) {
fileName = u':' + url.path(); fileName = u':' + url.path();
} else { } else {
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
if (scheme == QLatin1String("assets")) if (scheme == "assets"_L1)
fileName = QLatin1String("assets:") + url.path(); fileName = "assets:"_L1 + url.path();
else else
#endif #endif
fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery); fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery);
@ -224,7 +226,7 @@ qint64 QNetworkReplyFileImpl::readData(char *data, qint64 maxlen)
return -1; return -1;
else { else {
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200); setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200);
setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, QLatin1String("OK")); setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, "OK"_L1);
return ret; return ret;
} }
} }

View File

@ -67,6 +67,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
class QNetworkProxy; class QNetworkProxy;
static inline bool isSeparator(char c) static inline bool isSeparator(char c)
@ -182,7 +184,7 @@ QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager* const manage
d->outgoingData = outgoingData; d->outgoingData = outgoingData;
d->url = request.url(); d->url = request.url();
#ifndef QT_NO_SSL #ifndef QT_NO_SSL
if (request.url().scheme() == QLatin1String("https")) if (request.url().scheme() == "https"_L1)
d->sslConfiguration.reset(new QSslConfiguration(request.sslConfiguration())); d->sslConfiguration.reset(new QSslConfiguration(request.sslConfiguration()));
#endif #endif
@ -658,13 +660,11 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
httpRequest.setRedirectCount(newHttpRequest.maximumRedirectsAllowed()); httpRequest.setRedirectCount(newHttpRequest.maximumRedirectsAllowed());
QString scheme = url.scheme(); QString scheme = url.scheme();
bool ssl = (scheme == QLatin1String("https") bool ssl = (scheme == "https"_L1 || scheme == "preconnect-https"_L1);
|| scheme == QLatin1String("preconnect-https"));
q->setAttribute(QNetworkRequest::ConnectionEncryptedAttribute, ssl); q->setAttribute(QNetworkRequest::ConnectionEncryptedAttribute, ssl);
httpRequest.setSsl(ssl); httpRequest.setSsl(ssl);
bool preConnect = (scheme == QLatin1String("preconnect-http") bool preConnect = (scheme == "preconnect-http"_L1 || scheme == "preconnect-https"_L1);
|| scheme == QLatin1String("preconnect-https"));
httpRequest.setPreConnect(preConnect); httpRequest.setPreConnect(preConnect);
#ifndef QT_NO_NETWORKPROXY #ifndef QT_NO_NETWORKPROXY
@ -1235,13 +1235,12 @@ void QNetworkReplyHttpImplPrivate::onRedirected(const QUrl &redirectUrl, int htt
// equal to "80", the port component value MUST be preserved; // equal to "80", the port component value MUST be preserved;
// otherwise, if the URI does not contain an explicit port // otherwise, if the URI does not contain an explicit port
// component, the UA MUST NOT add one. // component, the UA MUST NOT add one.
url.setScheme(QLatin1String("https")); url.setScheme("https"_L1);
if (url.port() == 80) if (url.port() == 80)
url.setPort(443); url.setPort(443);
} }
const bool isLessSafe = schemeBefore == QLatin1String("https") const bool isLessSafe = schemeBefore == "https"_L1 && url.scheme() == "http"_L1;
&& url.scheme() == QLatin1String("http");
if (httpRequest.redirectPolicy() == QNetworkRequest::NoLessSafeRedirectPolicy if (httpRequest.redirectPolicy() == QNetworkRequest::NoLessSafeRedirectPolicy
&& isLessSafe) { && isLessSafe) {
error(QNetworkReply::InsecureRedirectError, error(QNetworkReply::InsecureRedirectError,
@ -1341,7 +1340,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByte
// RFC6797, 8.1 // RFC6797, 8.1
// If an HTTP response is received over insecure transport, the UA MUST // If an HTTP response is received over insecure transport, the UA MUST
// ignore any present STS header field(s). // ignore any present STS header field(s).
if (url.scheme() == QLatin1String("https") && managerPrivate->stsEnabled) if (url.scheme() == "https"_L1 && managerPrivate->stsEnabled)
managerPrivate->stsCache.updateFromHeaders(hm, url); managerPrivate->stsCache.updateFromHeaders(hm, url);
#endif #endif
// Download buffer // Download buffer

View File

@ -59,6 +59,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN(QNetworkRequest) QT_IMPL_METATYPE_EXTERN(QNetworkRequest)
QT_IMPL_METATYPE_EXTERN_TAGGED(QNetworkRequest::RedirectPolicy, QNetworkRequest__RedirectPolicy) QT_IMPL_METATYPE_EXTERN_TAGGED(QNetworkRequest::RedirectPolicy, QNetworkRequest__RedirectPolicy)
@ -1512,7 +1514,7 @@ QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value)
// eat the weekday, the comma and the space following it // eat the weekday, the comma and the space following it
QString sansWeekday = QString::fromLatin1(value.constData() + pos + 2); QString sansWeekday = QString::fromLatin1(value.constData() + pos + 2);
// must be RFC 850 date // must be RFC 850 date
dt = c.toDateTime(sansWeekday, QLatin1String("dd-MMM-yy hh:mm:ss 'GMT'")); dt = c.toDateTime(sansWeekday, "dd-MMM-yy hh:mm:ss 'GMT'"_L1);
} }
} }
#endif // datestring #endif // datestring

View File

@ -48,8 +48,10 @@
** **
****************************************************************************/ ****************************************************************************/
using namespace Qt::StringLiterals;
//! [0] //! [0]
QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem")); QList<QSslCertificate> cert = QSslCertificate::fromPath("server-certificate.pem"_L1);
QSslError error(QSslError::SelfSignedCertificate, cert.at(0)); QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
QList<QSslError> expectedSslErrors; QList<QSslError> expectedSslErrors;
expectedSslErrors.append(error); expectedSslErrors.append(error);

View File

@ -48,6 +48,7 @@
** **
****************************************************************************/ ****************************************************************************/
using namespace Qt::StringLiterals;
//! [0] //! [0]
// A client initiates a handshake: // A client initiates a handshake:
QUdpSocket clientSocket; QUdpSocket clientSocket;
@ -126,7 +127,7 @@ if (!dtls.doHandshake(&socket, dgram)) {
//! [5] //! [5]
//! [6] //! [6]
QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem")); QList<QSslCertificate> cert = QSslCertificate::fromPath("server-certificate.pem"_L1);
QSslError error(QSslError::SelfSignedCertificate, cert.at(0)); QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
QList<QSslError> expectedSslErrors; QList<QSslError> expectedSslErrors;
expectedSslErrors.append(error); expectedSslErrors.append(error);

View File

@ -48,6 +48,8 @@
** **
****************************************************************************/ ****************************************************************************/
using namespace Qt::StringLiterals;
//! [0] //! [0]
QSslSocket *socket = new QSslSocket(this); QSslSocket *socket = new QSslSocket(this);
connect(socket, SIGNAL(encrypted()), this, SLOT(ready())); connect(socket, SIGNAL(encrypted()), this, SLOT(ready()));
@ -107,7 +109,7 @@ if (socket->waitForEncrypted(1000))
//! [5] //! [5]
//! [6] //! [6]
QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem")); QList<QSslCertificate> cert = QSslCertificate::fromPath("server-certificate.pem"_L1);
QSslError error(QSslError::SelfSignedCertificate, cert.at(0)); QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
QList<QSslError> expectedSslErrors; QList<QSslError> expectedSslErrors;
expectedSslErrors.append(error); expectedSslErrors.append(error);

View File

@ -69,6 +69,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_DECLARE_LOGGING_CATEGORY(lcAuthenticator); Q_DECLARE_LOGGING_CATEGORY(lcAuthenticator);
Q_LOGGING_CATEGORY(lcAuthenticator, "qt.network.authenticator"); Q_LOGGING_CATEGORY(lcAuthenticator, "qt.network.authenticator");
@ -405,7 +407,7 @@ void QAuthenticatorPrivate::updateCredentials()
switch (method) { switch (method) {
case QAuthenticatorPrivate::Ntlm: case QAuthenticatorPrivate::Ntlm:
if ((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1) { if ((separatorPosn = user.indexOf("\\"_L1)) != -1) {
//domain name is present //domain name is present
realm.clear(); realm.clear();
userDomain = user.left(separatorPosn); userDomain = user.left(separatorPosn);
@ -522,7 +524,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QList<QPair<QByteArray, QByt
if (phase == Done) if (phase == Done)
phase = Start; phase = Start;
realm = newRealm; realm = newRealm;
this->options[QLatin1String("realm")] = realm; this->options["realm"_L1] = realm;
} }
}; };
@ -1658,7 +1660,7 @@ static QByteArray qSspiContinue(QAuthenticatorPrivate *ctx, QAuthenticatorPrivat
// Calculate target (SPN for Negotiate, empty for NTLM) // Calculate target (SPN for Negotiate, empty for NTLM)
std::wstring targetNameW = (method == QAuthenticatorPrivate::Negotiate std::wstring targetNameW = (method == QAuthenticatorPrivate::Negotiate
? QLatin1String("HTTP/") + host : QString()).toStdWString(); ? "HTTP/"_L1 + host : QString()).toStdWString();
// Generate our challenge-response message // Generate our challenge-response message
SECURITY_STATUS secStatus = pSecurityFunctionTable->InitializeSecurityContext( SECURITY_STATUS secStatus = pSecurityFunctionTable->InitializeSecurityContext(

View File

@ -67,6 +67,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
#if QT_CONFIG(library) #if QT_CONFIG(library)
#if defined(Q_OS_OPENBSD) #if defined(Q_OS_OPENBSD)
@ -111,7 +113,7 @@ static bool resolveLibraryInternal()
if (!lib.load()) if (!lib.load())
#endif #endif
{ {
lib.setFileName(QLatin1String("resolv")); lib.setFileName("resolv"_L1);
lib.load(); lib.load();
} }

View File

@ -70,6 +70,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
//#define QHOSTINFO_DEBUG //#define QHOSTINFO_DEBUG
QT_IMPL_METATYPE_EXTERN(QHostInfo) QT_IMPL_METATYPE_EXTERN(QHostInfo)
@ -536,7 +538,7 @@ QHostInfo QHostInfoAgent::lookup(const QString &hostName)
QString tmp; QString tmp;
QList<QHostAddress> addresses = results.addresses(); QList<QHostAddress> addresses = results.addresses();
for (int i = 0; i < addresses.count(); ++i) { for (int i = 0; i < addresses.count(); ++i) {
if (i != 0) tmp += QLatin1String(", "); if (i != 0) tmp += ", "_L1;
tmp += addresses.at(i).toString(); tmp += addresses.at(i).toString();
} }
qDebug("QHostInfoAgent::fromName(): found %i entries for \"%s\": {%s}", qDebug("QHostInfoAgent::fromName(): found %i entries for \"%s\": {%s}",

View File

@ -74,6 +74,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
enum LibResolvFeature { enum LibResolvFeature {
NeedResInit, NeedResInit,
NeedResNInit NeedResNInit
@ -129,7 +131,7 @@ LibResolv::LibResolv()
if (!lib.load()) if (!lib.load())
#endif #endif
{ {
lib.setFileName(QLatin1String("resolv")); lib.setFileName("resolv"_L1);
lib.load(); lib.load();
} }
@ -228,7 +230,7 @@ QString QHostInfo::localDomainName()
#if defined(_PATH_RESCONF) #if defined(_PATH_RESCONF)
resolvconf.setFileName(QFile::decodeName(_PATH_RESCONF)); resolvconf.setFileName(QFile::decodeName(_PATH_RESCONF));
#else #else
resolvconf.setFileName(QLatin1String("/etc/resolv.conf")); resolvconf.setFileName("/etc/resolv.conf"_L1);
#endif #endif
if (!resolvconf.open(QIODevice::ReadOnly)) if (!resolvconf.open(QIODevice::ReadOnly))
return QString(); // failure return QString(); // failure

View File

@ -243,6 +243,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN(QNetworkProxy) QT_IMPL_METATYPE_EXTERN(QNetworkProxy)
class QSocks5SocketEngineHandler; class QSocks5SocketEngineHandler;
@ -356,10 +358,8 @@ QList<QNetworkProxy> QGlobalNetworkProxy::proxyForQuery(const QNetworkProxyQuery
// don't look for proxies for a local connection // don't look for proxies for a local connection
QHostAddress parsed; QHostAddress parsed;
QString hostname = query.url().host(); QString hostname = query.url().host();
if (hostname == QLatin1String("localhost") if (hostname == "localhost"_L1 || hostname.startsWith("localhost."_L1)
|| hostname.startsWith(QLatin1String("localhost.")) || (parsed.setAddress(hostname) && (parsed.isLoopback()))) {
|| (parsed.setAddress(hostname)
&& (parsed.isLoopback()))) {
result << QNetworkProxy(QNetworkProxy::NoProxy); result << QNetworkProxy(QNetworkProxy::NoProxy);
return result; return result;
} }

View File

@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static bool ignoreProxyFor(const QNetworkProxyQuery &query) static bool ignoreProxyFor(const QNetworkProxyQuery &query)
{ {
const QByteArray noProxy = qgetenv("no_proxy").trimmed(); const QByteArray noProxy = qgetenv("no_proxy").trimmed();
@ -101,11 +103,11 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
const QString queryProtocol = query.protocolTag(); const QString queryProtocol = query.protocolTag();
QByteArray proxy_env; QByteArray proxy_env;
if (queryProtocol == QLatin1String("http")) if (queryProtocol == "http"_L1)
proxy_env = qgetenv("http_proxy"); proxy_env = qgetenv("http_proxy");
else if (queryProtocol == QLatin1String("https")) else if (queryProtocol == "https"_L1)
proxy_env = qgetenv("https_proxy"); proxy_env = qgetenv("https_proxy");
else if (queryProtocol == QLatin1String("ftp")) else if (queryProtocol == "ftp"_L1)
proxy_env = qgetenv("ftp_proxy"); proxy_env = qgetenv("ftp_proxy");
else else
proxy_env = qgetenv("all_proxy"); proxy_env = qgetenv("all_proxy");
@ -117,16 +119,16 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
if (!proxy_env.isEmpty()) { if (!proxy_env.isEmpty()) {
QUrl url = QUrl(QString::fromLocal8Bit(proxy_env)); QUrl url = QUrl(QString::fromLocal8Bit(proxy_env));
const QString scheme = url.scheme(); const QString scheme = url.scheme();
if (scheme == QLatin1String("socks5")) { if (scheme == "socks5"_L1) {
QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(), QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(),
url.port() ? url.port() : 1080, url.userName(), url.password()); url.port() ? url.port() : 1080, url.userName(), url.password());
proxyList << proxy; proxyList << proxy;
} else if (scheme == QLatin1String("socks5h")) { } else if (scheme == "socks5h"_L1) {
QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(), QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(),
url.port() ? url.port() : 1080, url.userName(), url.password()); url.port() ? url.port() : 1080, url.userName(), url.password());
proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability); proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability);
proxyList << proxy; proxyList << proxy;
} else if ((scheme.isEmpty() || scheme == QLatin1String("http")) } else if ((scheme.isEmpty() || scheme == "http"_L1)
&& query.queryType() != QNetworkProxyQuery::UdpSocket && query.queryType() != QNetworkProxyQuery::UdpSocket
&& query.queryType() != QNetworkProxyQuery::TcpServer) { && query.queryType() != QNetworkProxyQuery::TcpServer) {
QNetworkProxy proxy(QNetworkProxy::HttpProxy, url.host(), QNetworkProxy proxy(QNetworkProxy::HttpProxy, url.host(),

View File

@ -54,6 +54,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static bool isThreadingNeeded() static bool isThreadingNeeded()
{ {
// Try to guess if the libproxy we linked to is from the libproxy project // Try to guess if the libproxy we linked to is from the libproxy project
@ -221,14 +223,13 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
for (const QUrl& url : rawProxies) { for (const QUrl& url : rawProxies) {
QNetworkProxy::ProxyType type; QNetworkProxy::ProxyType type;
const QString scheme = url.scheme(); const QString scheme = url.scheme();
if (scheme == QLatin1String("http")) { if (scheme == "http"_L1) {
type = QNetworkProxy::HttpProxy; type = QNetworkProxy::HttpProxy;
} else if (scheme == QLatin1String("socks") } else if (scheme == "socks"_L1 || scheme == "socks5"_L1) {
|| scheme == QLatin1String("socks5")) {
type = QNetworkProxy::Socks5Proxy; type = QNetworkProxy::Socks5Proxy;
} else if (scheme == QLatin1String("ftp")) { } else if (scheme == "ftp"_L1) {
type = QNetworkProxy::FtpCachingProxy; type = QNetworkProxy::FtpCachingProxy;
} else if (scheme == QLatin1String("direct")) { } else if (scheme == "direct"_L1) {
type = QNetworkProxy::NoProxy; type = QNetworkProxy::NoProxy;
haveDirectConnection = true; haveDirectConnection = true;
} else { } else {

View File

@ -78,6 +78,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static bool isHostExcluded(CFDictionaryRef dict, const QString &host) static bool isHostExcluded(CFDictionaryRef dict, const QString &host)
{ {
if (host.isEmpty()) if (host.isEmpty())
@ -292,19 +294,19 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
// try the protocol-specific proxy // try the protocol-specific proxy
QNetworkProxy protocolSpecificProxy; QNetworkProxy protocolSpecificProxy;
if (protocol == QLatin1String("ftp")) { if (protocol == "ftp"_L1) {
protocolSpecificProxy = protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::FtpCachingProxy, proxyFromDictionary(dict, QNetworkProxy::FtpCachingProxy,
kSCPropNetProxiesFTPEnable, kSCPropNetProxiesFTPEnable,
kSCPropNetProxiesFTPProxy, kSCPropNetProxiesFTPProxy,
kSCPropNetProxiesFTPPort); kSCPropNetProxiesFTPPort);
} else if (protocol == QLatin1String("http")) { } else if (protocol == "http"_L1) {
protocolSpecificProxy = protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::HttpProxy, proxyFromDictionary(dict, QNetworkProxy::HttpProxy,
kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPEnable,
kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPProxy,
kSCPropNetProxiesHTTPPort); kSCPropNetProxiesHTTPPort);
} else if (protocol == QLatin1String("https")) { } else if (protocol == "https"_L1) {
isHttps = true; isHttps = true;
protocolSpecificProxy = protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::HttpProxy, proxyFromDictionary(dict, QNetworkProxy::HttpProxy,

View File

@ -57,6 +57,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static bool currentProcessIsService() static bool currentProcessIsService()
{ {
wchar_t userName[UNLEN + 1] = L""; wchar_t userName[UNLEN + 1] = L"";
@ -119,7 +121,7 @@ static bool isBypassed(const QString &host, const QStringList &bypassList)
// does it match the list of exclusions? // does it match the list of exclusions?
for (const QString &entry : bypassList) { for (const QString &entry : bypassList) {
if (entry == QLatin1String("<local>")) { if (entry == "<local>"_L1) {
if (isSimple) if (isSimple)
return true; return true;
if (isIpAddress) { if (isIpAddress) {
@ -231,20 +233,20 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
scheme = protocolTag = QStringView{entry}.left(pos); scheme = protocolTag = QStringView{entry}.left(pos);
server = pos + 1; server = pos + 1;
} }
pos = entry.indexOf(QLatin1String("://"), server); pos = entry.indexOf("://"_L1, server);
if (pos != -1) { if (pos != -1) {
scheme = QStringView{entry}.mid(server, pos - server); scheme = QStringView{entry}.mid(server, pos - server);
server = pos + 3; server = pos + 3;
} }
if (!scheme.isEmpty()) { if (!scheme.isEmpty()) {
if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) { if (scheme == "http"_L1 || scheme == "https"_L1) {
// no-op // no-op
// defaults are above // defaults are above
} else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) { } else if (scheme == "socks"_L1 || scheme == "socks5"_L1) {
proxyType = QNetworkProxy::Socks5Proxy; proxyType = QNetworkProxy::Socks5Proxy;
port = 1080; port = 1080;
} else if (scheme == QLatin1String("ftp")) { } else if (scheme == "ftp"_L1) {
proxyType = QNetworkProxy::FtpCachingProxy; proxyType = QNetworkProxy::FtpCachingProxy;
port = 2121; port = 2121;
} else { } else {
@ -279,10 +281,10 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
result.prepend(taggedProxies.value(requiredTag)); result.prepend(taggedProxies.value(requiredTag));
} }
} }
if (!checkTags || requiredTag != QLatin1String("http")) { if (!checkTags || requiredTag != "http"_L1) {
// if there are different http proxies for http and https, prefer the https one (more likely to be capable of CONNECT) // if there are different http proxies for http and https, prefer the https one (more likely to be capable of CONNECT)
QNetworkProxy httpProxy = taggedProxies.value(QLatin1String("http")); QNetworkProxy httpProxy = taggedProxies.value("http"_L1);
QNetworkProxy httpsProxy = taggedProxies.value(QLatin1String("http")); QNetworkProxy httpsProxy = taggedProxies.value("http"_L1);
if (httpProxy != httpsProxy && httpProxy.type() == QNetworkProxy::HttpProxy && httpsProxy.type() == QNetworkProxy::HttpProxy) { if (httpProxy != httpsProxy && httpProxy.type() == QNetworkProxy::HttpProxy && httpsProxy.type() == QNetworkProxy::HttpProxy) {
for (int i = 0; i < result.count(); i++) { for (int i = 0; i < result.count(); i++) {
if (httpProxy == result.at(i)) if (httpProxy == result.at(i))
@ -504,11 +506,11 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
// url could be empty, e.g. from QNetworkProxy::applicationProxy(), that's fine, // url could be empty, e.g. from QNetworkProxy::applicationProxy(), that's fine,
// we'll still ask for the proxy. // we'll still ask for the proxy.
// But for a file url, we know we don't need one. // But for a file url, we know we don't need one.
if (url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("qrc")) if (url.scheme() == "file"_L1 || url.scheme() == "qrc"_L1)
return sp->defaultResult; return sp->defaultResult;
if (query.queryType() != QNetworkProxyQuery::UrlRequest) { if (query.queryType() != QNetworkProxyQuery::UrlRequest) {
// change the scheme to https, maybe it'll work // change the scheme to https, maybe it'll work
url.setScheme(QLatin1String("https")); url.setScheme("https"_L1);
} }
QString urlQueryString = url.toString(); QString urlQueryString = url.toString();

View File

@ -500,6 +500,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN_TAGGED(QAbstractSocket::SocketState, QAbstractSocket__SocketState) QT_IMPL_METATYPE_EXTERN_TAGGED(QAbstractSocket::SocketState, QAbstractSocket__SocketState)
QT_IMPL_METATYPE_EXTERN_TAGGED(QAbstractSocket::SocketError, QAbstractSocket__SocketError) QT_IMPL_METATYPE_EXTERN_TAGGED(QAbstractSocket::SocketError, QAbstractSocket__SocketError)
@ -576,14 +578,14 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
Q_Q(QAbstractSocket); Q_Q(QAbstractSocket);
#if defined (QABSTRACTSOCKET_DEBUG) #if defined (QABSTRACTSOCKET_DEBUG)
QString typeStr; QString typeStr;
if (q->socketType() == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket"); if (q->socketType() == QAbstractSocket::TcpSocket) typeStr = "TcpSocket"_L1;
else if (q->socketType() == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket"); else if (q->socketType() == QAbstractSocket::UdpSocket) typeStr = "UdpSocket"_L1;
else if (q->socketType() == QAbstractSocket::SctpSocket) typeStr = QLatin1String("SctpSocket"); else if (q->socketType() == QAbstractSocket::SctpSocket) typeStr = "SctpSocket"_L1;
else typeStr = QLatin1String("UnknownSocketType"); else typeStr = "UnknownSocketType"_L1;
QString protocolStr; QString protocolStr;
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol"); if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = "IPv4Protocol"_L1;
else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol"); else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = "IPv6Protocol"_L1;
else protocolStr = QLatin1String("UnknownNetworkLayerProtocol"); else protocolStr = "UnknownNetworkLayerProtocol"_L1;
#endif #endif
resetSocketLayer(); resetSocketLayer();
@ -969,9 +971,9 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo)
#if defined(QABSTRACTSOCKET_DEBUG) #if defined(QABSTRACTSOCKET_DEBUG)
QString s = QLatin1String("{"); QString s = "{"_L1;
for (int i = 0; i < addresses.count(); ++i) { for (int i = 0; i < addresses.count(); ++i) {
if (i != 0) s += QLatin1String(", "); if (i != 0) s += ", "_L1;
s += addresses.at(i).toString(); s += addresses.at(i).toString();
} }
s += u'}'; s += u'}';

View File

@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
#define DEBUG #define DEBUG
QHttpSocketEngine::QHttpSocketEngine(QObject *parent) QHttpSocketEngine::QHttpSocketEngine(QObject *parent)
@ -186,8 +188,7 @@ bool QHttpSocketEngine::connectToHostByName(const QString &hostname, quint16 por
bool QHttpSocketEngine::bind(const QHostAddress &, quint16) bool QHttpSocketEngine::bind(const QHostAddress &, quint16)
{ {
qWarning("Operation is not supported"); qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
QLatin1String("Unsupported socket operation"));
return false; return false;
} }
@ -195,16 +196,14 @@ bool QHttpSocketEngine::listen(int backlog)
{ {
Q_UNUSED(backlog); Q_UNUSED(backlog);
qWarning("Operation is not supported"); qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
QLatin1String("Unsupported socket operation"));
return false; return false;
} }
int QHttpSocketEngine::accept() int QHttpSocketEngine::accept()
{ {
qWarning("Operation is not supported"); qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
QLatin1String("Unsupported socket operation"));
return -1; return -1;
} }
@ -239,8 +238,7 @@ qint64 QHttpSocketEngine::read(char *data, qint64 maxlen)
// failed, return the socket's error. Otherwise, fall through and // failed, return the socket's error. Otherwise, fall through and
// return as much as we read so far. // return as much as we read so far.
close(); close();
setError(QAbstractSocket::RemoteHostClosedError, setError(QAbstractSocket::RemoteHostClosedError, "Remote host closed"_L1);
QLatin1String("Remote host closed"));
setState(QAbstractSocket::UnconnectedState); setState(QAbstractSocket::UnconnectedState);
return -1; return -1;
} }
@ -259,8 +257,7 @@ bool QHttpSocketEngine::joinMulticastGroup(const QHostAddress &,
const QNetworkInterface &) const QNetworkInterface &)
{ {
qWarning("Operation is not supported"); qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
QLatin1String("Unsupported socket operation"));
return false; return false;
} }
@ -268,8 +265,7 @@ bool QHttpSocketEngine::leaveMulticastGroup(const QHostAddress &,
const QNetworkInterface &) const QNetworkInterface &)
{ {
qWarning("Operation is not supported"); qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
QLatin1String("Unsupported socket operation"));
return false; return false;
} }
@ -281,8 +277,7 @@ QNetworkInterface QHttpSocketEngine::multicastInterface() const
bool QHttpSocketEngine::setMulticastInterface(const QNetworkInterface &) bool QHttpSocketEngine::setMulticastInterface(const QNetworkInterface &)
{ {
qWarning("Operation is not supported"); qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
QLatin1String("Unsupported socket operation"));
return false; return false;
} }
#endif // QT_NO_NETWORKINTERFACE #endif // QT_NO_NETWORKINTERFACE
@ -303,16 +298,14 @@ qint64 QHttpSocketEngine::pendingDatagramSize() const
qint64 QHttpSocketEngine::readDatagram(char *, qint64, QIpPacketHeader *, PacketHeaderOptions) qint64 QHttpSocketEngine::readDatagram(char *, qint64, QIpPacketHeader *, PacketHeaderOptions)
{ {
qWarning("Operation is not supported"); qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
QLatin1String("Unsupported socket operation"));
return -1; return -1;
} }
qint64 QHttpSocketEngine::writeDatagram(const char *, qint64, const QIpPacketHeader &) qint64 QHttpSocketEngine::writeDatagram(const char *, qint64, const QIpPacketHeader &)
{ {
qWarning("Operation is not supported"); qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
QLatin1String("Unsupported socket operation"));
return -1; return -1;
} }

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/*! /*!
\class QLocalServer \class QLocalServer
\since 4.4 \since 4.4
@ -348,7 +350,7 @@ bool QLocalServer::listen(const QString &name)
if (name.isEmpty()) { if (name.isEmpty()) {
d->error = QAbstractSocket::HostNotFoundError; d->error = QAbstractSocket::HostNotFoundError;
QString function = QLatin1String("QLocalServer::listen"); QString function = "QLocalServer::listen"_L1;
d->errorString = tr("%1: Name error").arg(function); d->errorString = tr("%1: Name error").arg(function);
return false; return false;
} }

View File

@ -48,6 +48,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
void QLocalServerPrivate::init() void QLocalServerPrivate::init()
{ {
Q_Q(QLocalServer); Q_Q(QLocalServer);
@ -61,13 +63,13 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
if (!tcpServer.listen(QHostAddress::LocalHost)) if (!tcpServer.listen(QHostAddress::LocalHost))
return false; return false;
const QLatin1String prefix("QLocalServer/"); const auto prefix = "QLocalServer/"_L1;
if (requestedServerName.startsWith(prefix)) if (requestedServerName.startsWith(prefix))
fullServerName = requestedServerName; fullServerName = requestedServerName;
else else
fullServerName = prefix + requestedServerName; fullServerName = prefix + requestedServerName;
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt")); QSettings settings("QtProject"_L1, "Qt"_L1);
if (settings.contains(fullServerName)) { if (settings.contains(fullServerName)) {
qWarning("QLocalServer::listen: server name is already in use."); qWarning("QLocalServer::listen: server name is already in use.");
tcpServer.close(); tcpServer.close();
@ -85,8 +87,8 @@ bool QLocalServerPrivate::listen(qintptr socketDescriptor)
void QLocalServerPrivate::closeServer() void QLocalServerPrivate::closeServer()
{ {
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt")); QSettings settings("QtProject"_L1, "Qt"_L1);
if (fullServerName == QLatin1String("QLocalServer")) if (fullServerName == "QLocalServer"_L1)
settings.setValue(fullServerName, QVariant()); settings.setValue(fullServerName, QVariant());
else else
settings.remove(fullServerName); settings.remove(fullServerName);
@ -117,14 +119,14 @@ void QLocalServerPrivate::_q_onNewConnection()
bool QLocalServerPrivate::removeServer(const QString &name) bool QLocalServerPrivate::removeServer(const QString &name)
{ {
const QLatin1String prefix("QLocalServer/"); const auto prefix = "QLocalServer/"_L1;
QString serverName; QString serverName;
if (name.startsWith(prefix)) if (name.startsWith(prefix))
serverName = name; serverName = name;
else else
serverName = prefix + name; serverName = prefix + name;
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt")); QSettings settings("QtProject"_L1, "Qt"_L1);
if (settings.contains(serverName)) if (settings.contains(serverName))
settings.remove(serverName); settings.remove(serverName);

View File

@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace { namespace {
QLocalServer::SocketOptions optionsForPlatform(QLocalServer::SocketOptions srcOptions) QLocalServer::SocketOptions optionsForPlatform(QLocalServer::SocketOptions srcOptions)
{ {
@ -121,16 +123,16 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
QFileInfo serverNameFileInfo(fullServerName); QFileInfo serverNameFileInfo(fullServerName);
tempDir.emplace(serverNameFileInfo.absolutePath() + u'/'); tempDir.emplace(serverNameFileInfo.absolutePath() + u'/');
if (!tempDir->isValid()) { if (!tempDir->isValid()) {
setError(QLatin1String("QLocalServer::listen")); setError("QLocalServer::listen"_L1);
return false; return false;
} }
encodedTempPath = QFile::encodeName(tempDir->path() + QLatin1String("/s")); encodedTempPath = QFile::encodeName(tempDir->path() + "/s"_L1);
} }
// create the unix socket // create the unix socket
listenSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0); listenSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0);
if (-1 == listenSocket) { if (-1 == listenSocket) {
setError(QLatin1String("QLocalServer::listen")); setError("QLocalServer::listen"_L1);
closeServer(); closeServer();
return false; return false;
} }
@ -145,7 +147,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
constexpr unsigned int extraCharacters = PlatformSupportsAbstractNamespace ? 2 : 1; constexpr unsigned int extraCharacters = PlatformSupportsAbstractNamespace ? 2 : 1;
if (sizeof(addr.sun_path) < static_cast<size_t>(encodedFullServerName.size() + extraCharacters)) { if (sizeof(addr.sun_path) < static_cast<size_t>(encodedFullServerName.size() + extraCharacters)) {
setError(QLatin1String("QLocalServer::listen")); setError("QLocalServer::listen"_L1);
closeServer(); closeServer();
return false; return false;
} }
@ -159,7 +161,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
addrSize = offsetof(::sockaddr_un, sun_path) + encodedFullServerName.size() + 1; addrSize = offsetof(::sockaddr_un, sun_path) + encodedFullServerName.size() + 1;
} else if (options & QLocalServer::WorldAccessOption) { } else if (options & QLocalServer::WorldAccessOption) {
if (sizeof(addr.sun_path) < static_cast<size_t>(encodedTempPath.size() + 1)) { if (sizeof(addr.sun_path) < static_cast<size_t>(encodedTempPath.size() + 1)) {
setError(QLatin1String("QLocalServer::listen")); setError("QLocalServer::listen"_L1);
closeServer(); closeServer();
return false; return false;
} }
@ -172,7 +174,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
// bind // bind
if (-1 == QT_SOCKET_BIND(listenSocket, (sockaddr *)&addr, addrSize)) { if (-1 == QT_SOCKET_BIND(listenSocket, (sockaddr *)&addr, addrSize)) {
setError(QLatin1String("QLocalServer::listen")); setError("QLocalServer::listen"_L1);
// if address is in use already, just close the socket, but do not delete the file // if address is in use already, just close the socket, but do not delete the file
if (errno == EADDRINUSE) if (errno == EADDRINUSE)
QT_CLOSE(listenSocket); QT_CLOSE(listenSocket);
@ -185,7 +187,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
// listen for connections // listen for connections
if (-1 == qt_safe_listen(listenSocket, listenBacklog)) { if (-1 == qt_safe_listen(listenSocket, listenBacklog)) {
setError(QLatin1String("QLocalServer::listen")); setError("QLocalServer::listen"_L1);
closeServer(); closeServer();
return false; return false;
} }
@ -203,13 +205,13 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
mode |= S_IRWXO; mode |= S_IRWXO;
if (::chmod(encodedTempPath.constData(), mode) == -1) { if (::chmod(encodedTempPath.constData(), mode) == -1) {
setError(QLatin1String("QLocalServer::listen")); setError("QLocalServer::listen"_L1);
closeServer(); closeServer();
return false; return false;
} }
if (::rename(encodedTempPath.constData(), encodedFullServerName.constData()) == -1) { if (::rename(encodedTempPath.constData(), encodedFullServerName.constData()) == -1) {
setError(QLatin1String("QLocalServer::listen")); setError("QLocalServer::listen"_L1);
closeServer(); closeServer();
return false; return false;
} }
@ -301,7 +303,7 @@ void QLocalServerPrivate::_q_onNewConnection()
QT_SOCKLEN_T length = sizeof(sockaddr_un); QT_SOCKLEN_T length = sizeof(sockaddr_un);
int connectedSocket = qt_safe_accept(listenSocket, (sockaddr *)&addr, &length); int connectedSocket = qt_safe_accept(listenSocket, (sockaddr *)&addr, &length);
if (-1 == connectedSocket) { if (-1 == connectedSocket) {
setError(QLatin1String("QLocalSocket::activated")); setError("QLocalSocket::activated"_L1);
closeServer(); closeServer();
} else { } else {
socketNotifier->setEnabled(pendingConnections.size() socketNotifier->setEnabled(pendingConnections.size()
@ -330,7 +332,7 @@ void QLocalServerPrivate::waitForNewConnection(int msec, bool *timedOut)
errno = EBADF; errno = EBADF;
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case -1: case -1:
setError(QLatin1String("QLocalServer::waitForNewConnection")); setError("QLocalServer::waitForNewConnection"_L1);
closeServer(); closeServer();
break; break;
} }

View File

@ -55,6 +55,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
bool QLocalServerPrivate::addListener() bool QLocalServerPrivate::addListener()
{ {
// The object must not change its address once the // The object must not change its address once the
@ -77,7 +79,7 @@ bool QLocalServerPrivate::addListener()
if ((socketOptions.value() & QLocalServer::WorldAccessOption)) { if ((socketOptions.value() & QLocalServer::WorldAccessOption)) {
pSD.reset(new SECURITY_DESCRIPTOR); pSD.reset(new SECURITY_DESCRIPTOR);
if (!InitializeSecurityDescriptor(pSD.data(), SECURITY_DESCRIPTOR_REVISION)) { if (!InitializeSecurityDescriptor(pSD.data(), SECURITY_DESCRIPTOR_REVISION)) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
return false; return false;
} }
HANDLE hToken = NULL; HANDLE hToken = NULL;
@ -88,7 +90,7 @@ bool QLocalServerPrivate::addListener()
tokenUserBuffer.fill(0, dwBufferSize); tokenUserBuffer.fill(0, dwBufferSize);
auto pTokenUser = reinterpret_cast<PTOKEN_USER>(tokenUserBuffer.data()); auto pTokenUser = reinterpret_cast<PTOKEN_USER>(tokenUserBuffer.data());
if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwBufferSize, &dwBufferSize)) { if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwBufferSize, &dwBufferSize)) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
CloseHandle(hToken); CloseHandle(hToken);
return false; return false;
} }
@ -98,7 +100,7 @@ bool QLocalServerPrivate::addListener()
tokenGroupBuffer.fill(0, dwBufferSize); tokenGroupBuffer.fill(0, dwBufferSize);
auto pTokenGroup = reinterpret_cast<PTOKEN_PRIMARY_GROUP>(tokenGroupBuffer.data()); auto pTokenGroup = reinterpret_cast<PTOKEN_PRIMARY_GROUP>(tokenGroupBuffer.data());
if (!GetTokenInformation(hToken, TokenPrimaryGroup, pTokenGroup, dwBufferSize, &dwBufferSize)) { if (!GetTokenInformation(hToken, TokenPrimaryGroup, pTokenGroup, dwBufferSize, &dwBufferSize)) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
CloseHandle(hToken); CloseHandle(hToken);
return false; return false;
} }
@ -125,7 +127,7 @@ bool QLocalServerPrivate::addListener()
if (!AllocateAndInitializeSid(&WorldAuth, 1, SECURITY_WORLD_RID, if (!AllocateAndInitializeSid(&WorldAuth, 1, SECURITY_WORLD_RID,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
&worldSID)) { &worldSID)) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
return false; return false;
} }
@ -142,21 +144,21 @@ bool QLocalServerPrivate::addListener()
if (socketOptions.value() & QLocalServer::UserAccessOption) { if (socketOptions.value() & QLocalServer::UserAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenUser->User.Sid)) { if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenUser->User.Sid)) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID); FreeSid(worldSID);
return false; return false;
} }
} }
if (socketOptions.value() & QLocalServer::GroupAccessOption) { if (socketOptions.value() & QLocalServer::GroupAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenGroup->PrimaryGroup)) { if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenGroup->PrimaryGroup)) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID); FreeSid(worldSID);
return false; return false;
} }
} }
if (socketOptions.value() & QLocalServer::OtherAccessOption) { if (socketOptions.value() & QLocalServer::OtherAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, worldSID)) { if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, worldSID)) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID); FreeSid(worldSID);
return false; return false;
} }
@ -164,7 +166,7 @@ bool QLocalServerPrivate::addListener()
SetSecurityDescriptorOwner(pSD.data(), pTokenUser->User.Sid, FALSE); SetSecurityDescriptorOwner(pSD.data(), pTokenUser->User.Sid, FALSE);
SetSecurityDescriptorGroup(pSD.data(), pTokenGroup->PrimaryGroup, FALSE); SetSecurityDescriptorGroup(pSD.data(), pTokenGroup->PrimaryGroup, FALSE);
if (!SetSecurityDescriptorDacl(pSD.data(), TRUE, acl, FALSE)) { if (!SetSecurityDescriptorDacl(pSD.data(), TRUE, acl, FALSE)) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID); FreeSid(worldSID);
return false; return false;
} }
@ -185,7 +187,7 @@ bool QLocalServerPrivate::addListener()
&sa); &sa);
if (listener->handle == INVALID_HANDLE_VALUE) { if (listener->handle == INVALID_HANDLE_VALUE) {
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
listeners.pop_back(); listeners.pop_back();
return false; return false;
} }
@ -208,7 +210,7 @@ bool QLocalServerPrivate::addListener()
break; break;
default: default:
CloseHandle(listener->handle); CloseHandle(listener->handle);
setError(QLatin1String("QLocalServerPrivate::addListener")); setError("QLocalServerPrivate::addListener"_L1);
listeners.pop_back(); listeners.pop_back();
return false; return false;
} }
@ -240,7 +242,7 @@ bool QLocalServerPrivate::listen(const QString &name)
{ {
Q_Q(QLocalServer); Q_Q(QLocalServer);
const QLatin1String pipePath("\\\\.\\pipe\\"); const auto pipePath = "\\\\.\\pipe\\"_L1;
if (name.startsWith(pipePath)) if (name.startsWith(pipePath))
fullServerName = name; fullServerName = name;
else else
@ -300,7 +302,7 @@ void QLocalServerPrivate::_q_onNewConnection()
} else { } else {
if (GetLastError() != ERROR_IO_INCOMPLETE) { if (GetLastError() != ERROR_IO_INCOMPLETE) {
q->close(); q->close();
setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection")); setError("QLocalServerPrivate::_q_onNewConnection"_L1);
return; return;
} }

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(), QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),
tcpSocket(0), tcpSocket(0),
ownsTcpSocket(true), ownsTcpSocket(true),
@ -85,7 +87,7 @@ void QLocalSocketPrivate::setSocket(QLocalUnixSocket* socket)
void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError) void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError)
{ {
Q_Q(QLocalSocket); Q_Q(QLocalSocket);
QString function = QLatin1String("QLocalSocket"); QString function = "QLocalSocket"_L1;
QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError; QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError;
QString errorString = generateErrorString(error, function); QString errorString = generateErrorString(error, function);
q->setErrorString(errorString); q->setErrorString(errorString);
@ -225,23 +227,21 @@ void QLocalSocket::connectToServer(OpenMode openMode)
emit stateChanged(d->state); emit stateChanged(d->state);
if (d->serverName.isEmpty()) { if (d->serverName.isEmpty()) {
d->setErrorAndEmit(ServerNotFoundError, d->setErrorAndEmit(ServerNotFoundError, "QLocalSocket::connectToServer"_L1);
QLatin1String("QLocalSocket::connectToServer"));
return; return;
} }
const QLatin1String prefix("QLocalServer/"); const auto prefix = "QLocalServer/"_L1;
if (d->serverName.startsWith(prefix)) if (d->serverName.startsWith(prefix))
d->fullServerName = d->serverName; d->fullServerName = d->serverName;
else else
d->fullServerName = prefix + d->serverName; d->fullServerName = prefix + d->serverName;
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt")); QSettings settings("QtProject"_L1, "Qt"_L1);
bool ok; bool ok;
const quint16 port = settings.value(d->fullServerName).toUInt(&ok); const quint16 port = settings.value(d->fullServerName).toUInt(&ok);
if (!ok) { if (!ok) {
d->setErrorAndEmit(ServerNotFoundError, d->setErrorAndEmit(ServerNotFoundError, "QLocalSocket::connectToServer"_L1);
QLatin1String("QLocalSocket::connectToServer"));
return; return;
} }
QIODevice::open(openMode); QIODevice::open(openMode);

View File

@ -62,6 +62,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace { namespace {
// determine the full server path // determine the full server path
static QString pathNameForConnection(const QString &connectingName, static QString pathNameForConnection(const QString &connectingName,
@ -115,7 +117,7 @@ void QLocalSocketPrivate::init()
void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError) void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError)
{ {
Q_Q(QLocalSocket); Q_Q(QLocalSocket);
QString function = QLatin1String("QLocalSocket"); QString function = "QLocalSocket"_L1;
QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError; QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError;
QString errorString = generateErrorString(error, function); QString errorString = generateErrorString(error, function);
q->setErrorString(errorString); q->setErrorString(errorString);
@ -245,7 +247,7 @@ void QLocalSocket::connectToServer(OpenMode openMode)
{ {
Q_D(QLocalSocket); Q_D(QLocalSocket);
if (state() == ConnectedState || state() == ConnectingState) { if (state() == ConnectedState || state() == ConnectingState) {
QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver")); QString errorString = d->generateErrorString(QLocalSocket::OperationError, "QLocalSocket::connectToserver"_L1);
setErrorString(errorString); setErrorString(errorString);
emit errorOccurred(QLocalSocket::OperationError); emit errorOccurred(QLocalSocket::OperationError);
return; return;
@ -257,15 +259,13 @@ void QLocalSocket::connectToServer(OpenMode openMode)
emit stateChanged(d->state); emit stateChanged(d->state);
if (d->serverName.isEmpty()) { if (d->serverName.isEmpty()) {
d->setErrorAndEmit(ServerNotFoundError, d->setErrorAndEmit(ServerNotFoundError, "QLocalSocket::connectToServer"_L1);
QLatin1String("QLocalSocket::connectToServer"));
return; return;
} }
// create the socket // create the socket
if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, O_NONBLOCK))) { if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, O_NONBLOCK))) {
d->setErrorAndEmit(UnsupportedSocketOperationError, d->setErrorAndEmit(UnsupportedSocketOperationError, "QLocalSocket::connectToServer"_L1);
QLatin1String("QLocalSocket::connectToServer"));
return; return;
} }
@ -298,7 +298,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
constexpr unsigned int extraCharacters = PlatformSupportsAbstractNamespace ? 2 : 1; constexpr unsigned int extraCharacters = PlatformSupportsAbstractNamespace ? 2 : 1;
if (sizeof(addr.sun_path) < static_cast<size_t>(encodedConnectingPathName.size() + extraCharacters)) { if (sizeof(addr.sun_path) < static_cast<size_t>(encodedConnectingPathName.size() + extraCharacters)) {
QString function = QLatin1String("QLocalSocket::connectToServer"); QString function = "QLocalSocket::connectToServer"_L1;
setErrorAndEmit(QLocalSocket::ServerNotFoundError, function); setErrorAndEmit(QLocalSocket::ServerNotFoundError, function);
return; return;
} }
@ -313,7 +313,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
encodedConnectingPathName.size() + 1); encodedConnectingPathName.size() + 1);
} }
if (-1 == qt_safe_connect(connectingSocket, (struct sockaddr *)&addr, addrSize)) { if (-1 == qt_safe_connect(connectingSocket, (struct sockaddr *)&addr, addrSize)) {
QString function = QLatin1String("QLocalSocket::connectToServer"); QString function = "QLocalSocket::connectToServer"_L1;
switch (errno) switch (errno)
{ {
case EINVAL: case EINVAL:
@ -361,7 +361,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
q->QIODevice::open(connectingOpenMode); q->QIODevice::open(connectingOpenMode);
q->emit connected(); q->emit connected();
} else { } else {
QString function = QLatin1String("QLocalSocket::connectToServer"); QString function = "QLocalSocket::connectToServer"_L1;
setErrorAndEmit(QLocalSocket::UnknownSocketError, function); setErrorAndEmit(QLocalSocket::UnknownSocketError, function);
} }
connectingSocket = -1; connectingSocket = -1;
@ -632,7 +632,7 @@ bool QLocalSocket::waitForConnected(int msec)
if (result == -1) if (result == -1)
d->setErrorAndEmit(QLocalSocket::UnknownSocketError, d->setErrorAndEmit(QLocalSocket::UnknownSocketError,
QLatin1String("QLocalSocket::waitForConnected")); "QLocalSocket::waitForConnected"_L1);
else if (result > 0) else if (result > 0)
d->_q_connectToSocket(); d->_q_connectToSocket();
} while (state() == ConnectingState && !timer.hasExpired(msec)); } while (state() == ConnectingState && !timer.hasExpired(msec));

View File

@ -43,6 +43,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace { namespace {
struct QSocketPoller struct QSocketPoller
{ {
@ -197,14 +199,14 @@ void QLocalSocket::connectToServer(OpenMode openMode)
emit stateChanged(d->state); emit stateChanged(d->state);
if (d->serverName.isEmpty()) { if (d->serverName.isEmpty()) {
d->error = ServerNotFoundError; d->error = ServerNotFoundError;
d->errorString = tr("%1: Invalid name").arg(QLatin1String("QLocalSocket::connectToServer")); d->errorString = tr("%1: Invalid name").arg("QLocalSocket::connectToServer"_L1);
d->state = UnconnectedState; d->state = UnconnectedState;
emit errorOccurred(d->error); emit errorOccurred(d->error);
emit stateChanged(d->state); emit stateChanged(d->state);
return; return;
} }
const QLatin1String pipePath("\\\\.\\pipe\\"); const auto pipePath = "\\\\.\\pipe\\"_L1;
if (d->serverName.startsWith(pipePath)) if (d->serverName.startsWith(pipePath))
d->fullServerName = d->serverName; d->fullServerName = d->serverName;
else else
@ -237,7 +239,7 @@ void QLocalSocket::connectToServer(OpenMode openMode)
if (localSocket == INVALID_HANDLE_VALUE) { if (localSocket == INVALID_HANDLE_VALUE) {
const DWORD winError = GetLastError(); const DWORD winError = GetLastError();
d->_q_winError(winError, QLatin1String("QLocalSocket::connectToServer")); d->_q_winError(winError, "QLocalSocket::connectToServer"_L1);
d->fullServerName = QString(); d->fullServerName = QString();
return; return;
} }

View File

@ -135,6 +135,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
//#define QNATIVESOCKETENGINE_DEBUG //#define QNATIVESOCKETENGINE_DEBUG
#define Q_VOID #define Q_VOID
@ -448,13 +450,13 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb
// Create the socket // Create the socket
if (!d->createNewSocket(socketType, protocol)) { if (!d->createNewSocket(socketType, protocol)) {
#if defined (QNATIVESOCKETENGINE_DEBUG) #if defined (QNATIVESOCKETENGINE_DEBUG)
QString typeStr = QLatin1String("UnknownSocketType"); QString typeStr = "UnknownSocketType"_L1;
if (socketType == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket"); if (socketType == QAbstractSocket::TcpSocket) typeStr = "TcpSocket"_L1;
else if (socketType == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket"); else if (socketType == QAbstractSocket::UdpSocket) typeStr = "UdpSocket"_L1;
else if (socketType == QAbstractSocket::SctpSocket) typeStr = QLatin1String("SctpSocket"); else if (socketType == QAbstractSocket::SctpSocket) typeStr = "SctpSocket"_L1;
QString protocolStr = QLatin1String("UnknownProtocol"); QString protocolStr = "UnknownProtocol"_L1;
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol"); if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = "IPv4Protocol"_L1;
else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol"); else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = "IPv6Protocol"_L1;
qDebug("QNativeSocketEngine::initialize(type == %s, protocol == %s) failed: %s", qDebug("QNativeSocketEngine::initialize(type == %s, protocol == %s) failed: %s",
typeStr.toLatin1().constData(), protocolStr.toLatin1().constData(), d->socketErrorString.toLatin1().constData()); typeStr.toLatin1().constData(), protocolStr.toLatin1().constData(), d->socketErrorString.toLatin1().constData());
#endif #endif

View File

@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static const int MaxWriteBufferSize = 128*1024; static const int MaxWriteBufferSize = 128*1024;
//#define QSOCKS5SOCKETLAYER_DEBUG //#define QSOCKS5SOCKETLAYER_DEBUG
@ -102,22 +104,22 @@ static const int MaxWriteBufferSize = 128*1024;
static QString s5StateToString(QSocks5SocketEnginePrivate::Socks5State s) static QString s5StateToString(QSocks5SocketEnginePrivate::Socks5State s)
{ {
switch (s) { switch (s) {
case QSocks5SocketEnginePrivate::Uninitialized: return QLatin1String("Uninitialized"); case QSocks5SocketEnginePrivate::Uninitialized: return "Uninitialized"_L1;
case QSocks5SocketEnginePrivate::ConnectError: return QLatin1String("ConnectError"); case QSocks5SocketEnginePrivate::ConnectError: return "ConnectError"_L1;
case QSocks5SocketEnginePrivate::AuthenticationMethodsSent: return QLatin1String("AuthenticationMethodsSent"); case QSocks5SocketEnginePrivate::AuthenticationMethodsSent: return "AuthenticationMethodsSent"_L1;
case QSocks5SocketEnginePrivate::Authenticating: return QLatin1String("Authenticating"); case QSocks5SocketEnginePrivate::Authenticating: return "Authenticating"_L1;
case QSocks5SocketEnginePrivate::AuthenticatingError: return QLatin1String("AuthenticatingError"); case QSocks5SocketEnginePrivate::AuthenticatingError: return "AuthenticatingError"_L1;
case QSocks5SocketEnginePrivate::RequestMethodSent: return QLatin1String("RequestMethodSent"); case QSocks5SocketEnginePrivate::RequestMethodSent: return "RequestMethodSent"_L1;
case QSocks5SocketEnginePrivate::RequestError: return QLatin1String("RequestError"); case QSocks5SocketEnginePrivate::RequestError: return "RequestError"_L1;
case QSocks5SocketEnginePrivate::Connected: return QLatin1String("Connected"); case QSocks5SocketEnginePrivate::Connected: return "Connected"_L1;
case QSocks5SocketEnginePrivate::UdpAssociateSuccess: return QLatin1String("UdpAssociateSuccess"); case QSocks5SocketEnginePrivate::UdpAssociateSuccess: return "UdpAssociateSuccess"_L1;
case QSocks5SocketEnginePrivate::BindSuccess: return QLatin1String("BindSuccess"); case QSocks5SocketEnginePrivate::BindSuccess: return "BindSuccess"_L1;
case QSocks5SocketEnginePrivate::ControlSocketError: return QLatin1String("ControlSocketError"); case QSocks5SocketEnginePrivate::ControlSocketError: return "ControlSocketError"_L1;
case QSocks5SocketEnginePrivate::SocksError: return QLatin1String("SocksError"); case QSocks5SocketEnginePrivate::SocksError: return "SocksError"_L1;
case QSocks5SocketEnginePrivate::HostNameLookupError: return QLatin1String("HostNameLookupError"); case QSocks5SocketEnginePrivate::HostNameLookupError: return "HostNameLookupError"_L1;
default: break; default: break;
} }
return QLatin1String("unknown state"); return "unknown state"_L1;
} }
static QString dump(const QByteArray &buf) static QString dump(const QByteArray &buf)
@ -130,7 +132,7 @@ static QString dump(const QByteArray &buf)
data += QString::number(val); data += QString::number(val);
} }
if (buf.size() > MAX_DATA_DUMP) if (buf.size() > MAX_DATA_DUMP)
data += QLatin1String(" ..."); data += " ..."_L1;
return QString::fromLatin1("size: %1 data: { %2 }").arg(buf.size()).arg(data); return QString::fromLatin1("size: %1 data: { %2 }").arg(buf.size()).arg(data);
} }
@ -494,7 +496,7 @@ bool QSocks5PasswordAuthenticator::continueAuthenticate(QTcpSocket *socket, bool
QString QSocks5PasswordAuthenticator::errorString() QString QSocks5PasswordAuthenticator::errorString()
{ {
return QLatin1String("Socks5 user name or password incorrect"); return "Socks5 user name or password incorrect"_L1;
} }
@ -749,7 +751,7 @@ void QSocks5SocketEnginePrivate::parseAuthenticationMethodReply()
return; return;
} else if (buf.at(1) != data->authenticator->methodId() } else if (buf.at(1) != data->authenticator->methodId()
|| !data->authenticator->beginAuthenticate(data->controlSocket, &authComplete)) { || !data->authenticator->beginAuthenticate(data->controlSocket, &authComplete)) {
setErrorState(AuthenticatingError, QLatin1String("Socks5 host did not support authentication method.")); setErrorState(AuthenticatingError, "Socks5 host did not support authentication method."_L1);
socketError = QAbstractSocket::SocketAccessError; // change the socket error socketError = QAbstractSocket::SocketAccessError; // change the socket error
emitConnectionNotification(); emitConnectionNotification();
return; return;
@ -1102,7 +1104,7 @@ bool QSocks5SocketEngine::connectInternal()
} else if (socketType() == QAbstractSocket::UdpSocket) { } else if (socketType() == QAbstractSocket::UdpSocket) {
d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode); d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode);
// all udp needs to be bound // all udp needs to be bound
if (!bind(QHostAddress(QLatin1String("0.0.0.0")), 0)) if (!bind(QHostAddress("0.0.0.0"_L1), 0))
return false; return false;
setState(QAbstractSocket::ConnectedState); setState(QAbstractSocket::ConnectedState);
@ -1439,10 +1441,10 @@ int QSocks5SocketEngine::accept()
d->socketState = QAbstractSocket::UnconnectedState; d->socketState = QAbstractSocket::UnconnectedState;
break; break;
case QSocks5SocketEnginePrivate::ControlSocketError: case QSocks5SocketEnginePrivate::ControlSocketError:
setError(QAbstractSocket::ProxyProtocolError, QLatin1String("Control socket error")); setError(QAbstractSocket::ProxyProtocolError, "Control socket error"_L1);
break; break;
default: default:
setError(QAbstractSocket::ProxyProtocolError, QLatin1String("SOCKS5 proxy error")); setError(QAbstractSocket::ProxyProtocolError, "SOCKS5 proxy error"_L1);
break; break;
} }
return sd; return sd;
@ -1494,7 +1496,7 @@ qint64 QSocks5SocketEngine::read(char *data, qint64 maxlen)
//imitate remote closed //imitate remote closed
close(); close();
setError(QAbstractSocket::RemoteHostClosedError, setError(QAbstractSocket::RemoteHostClosedError,
QLatin1String("Remote host closed connection###")); "Remote host closed connection###"_L1);
setState(QAbstractSocket::UnconnectedState); setState(QAbstractSocket::UnconnectedState);
return -1; return -1;
} else { } else {
@ -1557,7 +1559,7 @@ bool QSocks5SocketEngine::joinMulticastGroup(const QHostAddress &,
const QNetworkInterface &) const QNetworkInterface &)
{ {
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Operation on socket is not supported")); "Operation on socket is not supported"_L1);
return false; return false;
} }
@ -1565,7 +1567,7 @@ bool QSocks5SocketEngine::leaveMulticastGroup(const QHostAddress &,
const QNetworkInterface &) const QNetworkInterface &)
{ {
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Operation on socket is not supported")); "Operation on socket is not supported"_L1);
return false; return false;
} }
@ -1578,7 +1580,7 @@ QNetworkInterface QSocks5SocketEngine::multicastInterface() const
bool QSocks5SocketEngine::setMulticastInterface(const QNetworkInterface &) bool QSocks5SocketEngine::setMulticastInterface(const QNetworkInterface &)
{ {
setError(QAbstractSocket::UnsupportedSocketOperationError, setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Operation on socket is not supported")); "Operation on socket is not supported"_L1);
return false; return false;
} }
#endif // QT_NO_NETWORKINTERFACE #endif // QT_NO_NETWORKINTERFACE
@ -1634,7 +1636,7 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI
if (!d->data) { if (!d->data) {
d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode); d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode);
// all udp needs to be bound // all udp needs to be bound
if (!bind(QHostAddress(QLatin1String("0.0.0.0")), 0)) { if (!bind(QHostAddress("0.0.0.0"_L1), 0)) {
//### set error //### set error
return -1; return -1;
} }

View File

@ -151,6 +151,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN(QSslCertificate) QT_IMPL_METATYPE_EXTERN(QSslCertificate)
QSslCertificatePrivate::QSslCertificatePrivate() QSslCertificatePrivate::QSslCertificatePrivate()
@ -665,9 +667,9 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
if (syntax == PatternSyntax::Wildcard) if (syntax == PatternSyntax::Wildcard)
pos = pathPrefix.indexOf(QRegularExpression(QLatin1String("[*?[]"))); pos = pathPrefix.indexOf(QRegularExpression("[*?[]"_L1));
else if (syntax == PatternSyntax::RegularExpression) else if (syntax == PatternSyntax::RegularExpression)
pos = sourcePath.indexOf(QRegularExpression(QLatin1String("[\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]"))); pos = sourcePath.indexOf(QRegularExpression("[\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]"_L1));
#else #else
if (syntax == PatternSyntax::Wildcard || syntax == PatternSyntax::RegExp) if (syntax == PatternSyntax::Wildcard || syntax == PatternSyntax::RegExp)
qWarning("Regular expression support is disabled in this build. Only fixed string can be searched"); qWarning("Regular expression support is disabled in this build. Only fixed string can be searched");
@ -698,7 +700,7 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
// Special case - if the prefix ends up being nothing, use "." instead. // Special case - if the prefix ends up being nothing, use "." instead.
int startIndex = 0; int startIndex = 0;
if (pathPrefix.isEmpty()) { if (pathPrefix.isEmpty()) {
pathPrefix = QLatin1String("."); pathPrefix = "."_L1;
startIndex = 2; startIndex = 2;
} }

View File

@ -399,6 +399,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
class QSslSocketGlobalData class QSslSocketGlobalData
{ {
public: public:
@ -2085,12 +2087,12 @@ void QSslSocketPrivate::init()
*/ */
bool QSslSocketPrivate::verifyProtocolSupported(const char *where) bool QSslSocketPrivate::verifyProtocolSupported(const char *where)
{ {
QLatin1String protocolName("DTLS"); auto protocolName = "DTLS"_L1;
switch (configuration.protocol) { switch (configuration.protocol) {
case QSsl::UnknownProtocol: case QSsl::UnknownProtocol:
// UnknownProtocol, according to our docs, is for cipher whose protocol is unknown. // UnknownProtocol, according to our docs, is for cipher whose protocol is unknown.
// Should not be used when configuring QSslSocket. // Should not be used when configuring QSslSocket.
protocolName = QLatin1String("UnknownProtocol"); protocolName = "UnknownProtocol"_L1;
Q_FALLTHROUGH(); Q_FALLTHROUGH();
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_DEPRECATED
@ -3078,7 +3080,7 @@ bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hos
// 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
// domain name (RFC6125 section 7.2) // domain name (RFC6125 section 7.2)
if (cn.startsWith(QLatin1String("xn--"), Qt::CaseInsensitive)) if (cn.startsWith("xn--"_L1, Qt::CaseInsensitive))
return false; return false;
// Check characters preceding * (if any) match // Check characters preceding * (if any) match

View File

@ -61,6 +61,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_APPLICATION_STATIC(QFactoryLoader, loader, QTlsBackend_iid, Q_APPLICATION_STATIC(QFactoryLoader, loader, QTlsBackend_iid,
QStringLiteral("/tls")) QStringLiteral("/tls"))
@ -832,13 +834,13 @@ QT_WARNING_DISABLE_DEPRECATED
} }
QT_WARNING_POP QT_WARNING_POP
if (descriptionList.at(2).startsWith(QLatin1String("Kx="))) if (descriptionList.at(2).startsWith("Kx="_L1))
ciph.d->keyExchangeMethod = descriptionList.at(2).mid(3).toString(); ciph.d->keyExchangeMethod = descriptionList.at(2).mid(3).toString();
if (descriptionList.at(3).startsWith(QLatin1String("Au="))) if (descriptionList.at(3).startsWith("Au="_L1))
ciph.d->authenticationMethod = descriptionList.at(3).mid(3).toString(); ciph.d->authenticationMethod = descriptionList.at(3).mid(3).toString();
if (descriptionList.at(4).startsWith(QLatin1String("Enc="))) if (descriptionList.at(4).startsWith("Enc="_L1))
ciph.d->encryptionMethod = descriptionList.at(4).mid(4).toString(); ciph.d->encryptionMethod = descriptionList.at(4).mid(4).toString();
ciph.d->exportable = (descriptionList.size() > 6 && descriptionList.at(6) == QLatin1String("export")); ciph.d->exportable = (descriptionList.size() > 6 && descriptionList.at(6) == "export"_L1);
ciph.d->bits = bits; ciph.d->bits = bits;
ciph.d->supportedBits = supportedBits; ciph.d->supportedBits = supportedBits;
@ -852,7 +854,7 @@ QT_WARNING_POP
Auxiliary function. Creates a new QSslCipher from \a suiteName, \a protocol version and Auxiliary function. Creates a new QSslCipher from \a suiteName, \a protocol version and
\a protocolString. For example: \a protocolString. For example:
\code \code
createCiphersuite(QLatin1String("ECDHE-RSA-AES256-GCM-SHA256"), QSsl::TlsV1_2, QLatin1String("TLSv1.2")); createCiphersuite("ECDHE-RSA-AES256-GCM-SHA256"_L1, QSsl::TlsV1_2, "TLSv1.2"_L1);
\endcode \endcode
*/ */
QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslProtocol protocol, QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslProtocol protocol,
@ -871,49 +873,49 @@ QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslPro
const auto bits = QStringView{ciph.d->name}.split(u'-'); 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 = "RSA"_L1;
else if (bits.front() == QLatin1String("DH") || bits.front() == QLatin1String("DHE")) else if (bits.front() == "DH"_L1 || bits.front() == "DHE"_L1)
ciph.d->keyExchangeMethod = QLatin1String("DH"); ciph.d->keyExchangeMethod = "DH"_L1;
else if (bits.front() == QLatin1String("ECDH") || bits.front() == QLatin1String("ECDHE")) else if (bits.front() == "ECDH"_L1 || bits.front() == "ECDHE"_L1)
ciph.d->keyExchangeMethod = QLatin1String("ECDH"); ciph.d->keyExchangeMethod = "ECDH"_L1;
else else
qCWarning(lcSsl) << "Unknown Kx" << ciph.d->name; qCWarning(lcSsl) << "Unknown Kx" << ciph.d->name;
if (bits.size() == 2 || bits.size() == 3) if (bits.size() == 2 || bits.size() == 3)
ciph.d->authenticationMethod = QLatin1String("RSA"); ciph.d->authenticationMethod = "RSA"_L1;
else if (ciph.d->name.contains(QLatin1String("-ECDSA-"))) else if (ciph.d->name.contains("-ECDSA-"_L1))
ciph.d->authenticationMethod = QLatin1String("ECDSA"); ciph.d->authenticationMethod = "ECDSA"_L1;
else if (ciph.d->name.contains(QLatin1String("-RSA-"))) else if (ciph.d->name.contains("-RSA-"_L1))
ciph.d->authenticationMethod = QLatin1String("RSA"); ciph.d->authenticationMethod = "RSA"_L1;
else else
qCWarning(lcSsl) << "Unknown Au" << ciph.d->name; qCWarning(lcSsl) << "Unknown Au" << ciph.d->name;
if (ciph.d->name.contains(QLatin1String("RC4-"))) { if (ciph.d->name.contains("RC4-"_L1)) {
ciph.d->encryptionMethod = QLatin1String("RC4(128)"); ciph.d->encryptionMethod = "RC4(128)"_L1;
ciph.d->bits = 128; ciph.d->bits = 128;
ciph.d->supportedBits = 128; ciph.d->supportedBits = 128;
} else if (ciph.d->name.contains(QLatin1String("DES-CBC3-"))) { } else if (ciph.d->name.contains("DES-CBC3-"_L1)) {
ciph.d->encryptionMethod = QLatin1String("3DES(168)"); ciph.d->encryptionMethod = "3DES(168)"_L1;
ciph.d->bits = 168; ciph.d->bits = 168;
ciph.d->supportedBits = 168; ciph.d->supportedBits = 168;
} else if (ciph.d->name.contains(QLatin1String("AES128-"))) { } else if (ciph.d->name.contains("AES128-"_L1)) {
ciph.d->encryptionMethod = QLatin1String("AES(128)"); ciph.d->encryptionMethod = "AES(128)"_L1;
ciph.d->bits = 128; ciph.d->bits = 128;
ciph.d->supportedBits = 128; ciph.d->supportedBits = 128;
} else if (ciph.d->name.contains(QLatin1String("AES256-GCM"))) { } else if (ciph.d->name.contains("AES256-GCM"_L1)) {
ciph.d->encryptionMethod = QLatin1String("AESGCM(256)"); ciph.d->encryptionMethod = "AESGCM(256)"_L1;
ciph.d->bits = 256; ciph.d->bits = 256;
ciph.d->supportedBits = 256; ciph.d->supportedBits = 256;
} else if (ciph.d->name.contains(QLatin1String("AES256-"))) { } else if (ciph.d->name.contains("AES256-"_L1)) {
ciph.d->encryptionMethod = QLatin1String("AES(256)"); ciph.d->encryptionMethod = "AES(256)"_L1;
ciph.d->bits = 256; ciph.d->bits = 256;
ciph.d->supportedBits = 256; ciph.d->supportedBits = 256;
} else if (ciph.d->name.contains(QLatin1String("CHACHA20-"))) { } else if (ciph.d->name.contains("CHACHA20-"_L1)) {
ciph.d->encryptionMethod = QLatin1String("CHACHA20"); ciph.d->encryptionMethod = "CHACHA20"_L1;
ciph.d->bits = 256; ciph.d->bits = 256;
ciph.d->supportedBits = 256; ciph.d->supportedBits = 256;
} else if (ciph.d->name.contains(QLatin1String("NULL-"))) { } else if (ciph.d->name.contains("NULL-"_L1)) {
ciph.d->encryptionMethod = QLatin1String("NULL"); ciph.d->encryptionMethod = "NULL"_L1;
} else { } else {
qCWarning(lcSsl) << "Unknown Enc" << ciph.d->name; qCWarning(lcSsl) << "Unknown Enc" << ciph.d->name;
} }
@ -926,7 +928,7 @@ QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslPro
Auxiliary function. Creates a new QSslCipher from \a name (which is an implementation-specific Auxiliary function. Creates a new QSslCipher from \a name (which is an implementation-specific
string), \a protocol and \a protocolString, e.g.: string), \a protocol and \a protocolString, e.g.:
\code \code
createCipher(QStringLiteral("schannel"), QSsl::TlsV1_2, QLatin1String("TLSv1.2")); createCipher(QStringLiteral("schannel"), QSsl::TlsV1_2, "TLSv1.2"_L1);
\endcode \endcode
*/ */
QSslCipher QTlsBackend::createCipher(const QString &name, QSsl::SslProtocol protocol, QSslCipher QTlsBackend::createCipher(const QString &name, QSsl::SslProtocol protocol,

View File

@ -45,6 +45,9 @@
#include <gio/gio.h> #include <gio/gio.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_DECLARE_LOGGING_CATEGORY(lcNetInfoGlib) Q_DECLARE_LOGGING_CATEGORY(lcNetInfoGlib)
Q_LOGGING_CATEGORY(lcNetInfoGlib, "qt.network.info.glib"); Q_LOGGING_CATEGORY(lcNetInfoGlib, "qt.network.info.glib");
@ -141,7 +144,7 @@ QGlibNetworkInformationBackend::~QGlibNetworkInformationBackend()
bool QGlibNetworkInformationBackend::isValid() const bool QGlibNetworkInformationBackend::isValid() const
{ {
return G_OBJECT_TYPE_NAME(networkMonitor) != QLatin1String("GNetworkMonitorBase"); return G_OBJECT_TYPE_NAME(networkMonitor) != "GNetworkMonitorBase"_L1;
} }
void QGlibNetworkInformationBackend::updateInformation(QGlibNetworkInformationBackend *backend) void QGlibNetworkInformationBackend::updateInformation(QGlibNetworkInformationBackend *backend)

View File

@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals; using namespace Qt::StringLiterals;
QNetworkManagerInterfaceBase::QNetworkManagerInterfaceBase(QObject *parent) QNetworkManagerInterfaceBase::QNetworkManagerInterfaceBase(QObject *parent)
: QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), : QDBusAbstractInterface(NM_DBUS_SERVICE ""_L1, NM_DBUS_PATH ""_L1,
NM_DBUS_INTERFACE, QDBusConnection::systemBus(), parent) NM_DBUS_INTERFACE, QDBusConnection::systemBus(), parent)
{ {
} }
@ -81,29 +81,27 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
return; return;
PropertiesDBusInterface managerPropertiesInterface( PropertiesDBusInterface managerPropertiesInterface(
QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), DBUS_PROPERTIES_INTERFACE, NM_DBUS_SERVICE ""_L1, NM_DBUS_PATH ""_L1, DBUS_PROPERTIES_INTERFACE,
QDBusConnection::systemBus()); QDBusConnection::systemBus());
QList<QVariant> argumentList; QList<QVariant> argumentList;
argumentList << QLatin1String(NM_DBUS_INTERFACE); argumentList << NM_DBUS_INTERFACE ""_L1;
QDBusPendingReply<QVariantMap> propsReply = managerPropertiesInterface.callWithArgumentList( QDBusPendingReply<QVariantMap> propsReply = managerPropertiesInterface.callWithArgumentList(
QDBus::Block, QLatin1String("GetAll"), argumentList); QDBus::Block, "GetAll"_L1, argumentList);
if (!propsReply.isError()) { if (!propsReply.isError()) {
propertyMap = propsReply.value(); propertyMap = propsReply.value();
} else { } else {
qWarning() << "propsReply" << propsReply.error().message(); qWarning() << "propsReply" << propsReply.error().message();
} }
QDBusConnection::systemBus().connect( QDBusConnection::systemBus().connect(NM_DBUS_SERVICE ""_L1, NM_DBUS_PATH ""_L1,
QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), DBUS_PROPERTIES_INTERFACE""_L1, "PropertiesChanged"_L1, this,
QLatin1String(DBUS_PROPERTIES_INTERFACE), QLatin1String("PropertiesChanged"), this,
SLOT(setProperties(QString, QMap<QString, QVariant>, QList<QString>))); SLOT(setProperties(QString, QMap<QString, QVariant>, QList<QString>)));
} }
QNetworkManagerInterface::~QNetworkManagerInterface() QNetworkManagerInterface::~QNetworkManagerInterface()
{ {
QDBusConnection::systemBus().disconnect( QDBusConnection::systemBus().disconnect(NM_DBUS_SERVICE ""_L1, NM_DBUS_PATH ""_L1,
QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), DBUS_PROPERTIES_INTERFACE ""_L1, "PropertiesChanged"_L1, this,
QLatin1String(DBUS_PROPERTIES_INTERFACE), QLatin1String("PropertiesChanged"), this,
SLOT(setProperties(QString, QMap<QString, QVariant>, QList<QString>))); SLOT(setProperties(QString, QMap<QString, QVariant>, QList<QString>)));
} }
@ -202,17 +200,17 @@ void QNetworkManagerInterface::setProperties(const QString &interfaceName,
} }
if (valueChanged) { if (valueChanged) {
if (i.key() == QLatin1String("State")) { if (i.key() == "State"_L1) {
quint32 state = i.value().toUInt(); quint32 state = i.value().toUInt();
Q_EMIT stateChanged(static_cast<NMState>(state)); Q_EMIT stateChanged(static_cast<NMState>(state));
} else if (i.key() == QLatin1String("Connectivity")) { } else if (i.key() == "Connectivity"_L1) {
quint32 state = i.value().toUInt(); quint32 state = i.value().toUInt();
Q_EMIT connectivityChanged(static_cast<NMConnectivityState>(state)); Q_EMIT connectivityChanged(static_cast<NMConnectivityState>(state));
} else if (i.key() == QLatin1String("PrimaryConnection")) { } else if (i.key() == "PrimaryConnection"_L1) {
const QDBusObjectPath devicePath = i->value<QDBusObjectPath>(); const QDBusObjectPath devicePath = i->value<QDBusObjectPath>();
Q_EMIT deviceTypeChanged(extractDeviceType(devicePath)); Q_EMIT deviceTypeChanged(extractDeviceType(devicePath));
Q_EMIT meteredChanged(extractDeviceMetered(devicePath)); Q_EMIT meteredChanged(extractDeviceMetered(devicePath));
} else if (i.key() == QLatin1String("Metered")) { } else if (i.key() == "Metered"_L1) {
Q_EMIT meteredChanged(static_cast<NMMetered>(i->toUInt())); Q_EMIT meteredChanged(static_cast<NMMetered>(i->toUInt()));
} }
} }

View File

@ -81,6 +81,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/* /*
Note to maintainer: Note to maintainer:
------------------- -------------------
@ -628,12 +630,12 @@ static QStringList libraryPathList()
# else # else
paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts); paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
# endif # endif
paths << QLatin1String("/lib") << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib"); paths << "/lib"_L1 << "/usr/lib"_L1 << "/usr/local/lib"_L1;
paths << QLatin1String("/lib64") << QLatin1String("/usr/lib64") << QLatin1String("/usr/local/lib64"); paths << "/lib64"_L1 << "/usr/lib64"_L1 << "/usr/local/lib64"_L1;
paths << QLatin1String("/lib32") << QLatin1String("/usr/lib32") << QLatin1String("/usr/local/lib32"); paths << "/lib32"_L1 << "/usr/lib32"_L1 << "/usr/local/lib32"_L1;
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
paths << QLatin1String("/system/lib"); paths << "/system/lib"_L1;
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
// discover paths of already loaded libraries // discover paths of already loaded libraries
QDuplicateTracker<QString> loadedPaths; QDuplicateTracker<QString> loadedPaths;
@ -665,12 +667,12 @@ static QStringList findAllLibs(QLatin1String filter)
static QStringList findAllLibSsl() static QStringList findAllLibSsl()
{ {
return findAllLibs(QLatin1String("libssl.*")); return findAllLibs("libssl.*"_L1);
} }
static QStringList findAllLibCrypto() static QStringList findAllLibCrypto()
{ {
return findAllLibs(QLatin1String("libcrypto.*")); return findAllLibs("libcrypto.*"_L1);
} }
# endif # endif
@ -721,8 +723,8 @@ static LoadedOpenSsl loadOpenSsl()
#define QT_SSL_SUFFIX #define QT_SSL_SUFFIX
#endif #endif
tryToLoadOpenSslWin32Library(QLatin1String("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX), tryToLoadOpenSslWin32Library("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1,
QLatin1String("libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX), result); "libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1, result);
#undef QT_SSL_SUFFIX #undef QT_SSL_SUFFIX
return result; return result;
@ -779,8 +781,8 @@ static LoadedOpenSsl loadOpenSsl()
#endif #endif
#if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so #if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
// first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER> // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
libssl->setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER)); libssl->setFileNameAndVersion("ssl"_L1, SHLIB_VERSION_NUMBER ""_L1);
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER)); libcrypto->setFileNameAndVersion("crypto"_L1, SHLIB_VERSION_NUMBER ""_L1);
if (libcrypto->load() && libssl->load()) { if (libcrypto->load() && libssl->load()) {
// libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
return result; return result;
@ -808,11 +810,11 @@ static LoadedOpenSsl loadOpenSsl()
static QString suffix = QString::fromLatin1(openSSLSuffix("_1_1")); static QString suffix = QString::fromLatin1(openSSLSuffix("_1_1"));
libssl->setFileNameAndVersion(QLatin1String("ssl") + suffix, -1); libssl->setFileNameAndVersion("ssl"_L1 + suffix, -1);
libcrypto->setFileNameAndVersion(QLatin1String("crypto") + suffix, -1); libcrypto->setFileNameAndVersion("crypto"_L1 + suffix, -1);
# else # else
libssl->setFileNameAndVersion(QLatin1String("ssl"), -1); libssl->setFileNameAndVersion("ssl"_L1, -1);
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1); libcrypto->setFileNameAndVersion("crypto"_L1, -1);
# endif # endif
if (libcrypto->load() && libssl->load()) { if (libcrypto->load() && libssl->load()) {
// libssl.so.0 and libcrypto.so.0 found // libssl.so.0 and libcrypto.so.0 found

View File

@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace { namespace {
QSsl::AlertLevel tlsAlertLevel(int value) QSsl::AlertLevel tlsAlertLevel(int value)
@ -85,7 +87,7 @@ QString tlsAlertDescription(int value)
{ {
QString description = QLatin1String(q_SSL_alert_desc_string_long(value)); QString description = QLatin1String(q_SSL_alert_desc_string_long(value));
if (!description.size()) if (!description.size())
description = QLatin1String("no description provided"); description = "no description provided"_L1;
return description; return description;
} }
@ -822,7 +824,7 @@ void TlsCryptographOpenSSL::continueHandshake()
debugLineClientRandom.append(masterKey.toHex().toUpper()); debugLineClientRandom.append(masterKey.toHex().toUpper());
debugLineClientRandom.append("\n"); debugLineClientRandom.append("\n");
QString sslKeyFile = QDir::tempPath() + QLatin1String("/qt-ssl-keys"); QString sslKeyFile = QDir::tempPath() + "/qt-ssl-keys"_L1;
QFile file(sslKeyFile); QFile file(sslKeyFile);
if (!file.open(QIODevice::Append)) if (!file.open(QIODevice::Append))
qCWarning(lcTlsBackend) << "could not open file" << sslKeyFile << "for appending"; qCWarning(lcTlsBackend) << "could not open file" << sslKeyFile << "for appending";

View File

@ -65,6 +65,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_LOGGING_CATEGORY(lcTlsBackend, "qt.tlsbackend.ossl"); Q_LOGGING_CATEGORY(lcTlsBackend, "qt.tlsbackend.ossl");
Q_GLOBAL_STATIC(QRecursiveMutex, qt_opensslInitMutex) Q_GLOBAL_STATIC(QRecursiveMutex, qt_opensslInitMutex)
@ -80,9 +82,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
const auto ciph = QTlsBackendOpenSSL::qt_OpenSSL_cipher_to_QSslCipher(cipher); const auto ciph = QTlsBackendOpenSSL::qt_OpenSSL_cipher_to_QSslCipher(cipher);
if (!ciph.isNull()) { if (!ciph.isNull()) {
// Unconditionally exclude ADH and AECDH ciphers since they offer no MITM protection // Unconditionally exclude ADH and AECDH ciphers since they offer no MITM protection
if (!ciph.name().toLower().startsWith(QLatin1String("adh")) && if (!ciph.name().toLower().startsWith("adh"_L1) &&
!ciph.name().toLower().startsWith(QLatin1String("exp-adh")) && !ciph.name().toLower().startsWith("exp-adh"_L1) &&
!ciph.name().toLower().startsWith(QLatin1String("aecdh"))) { !ciph.name().toLower().startsWith("aecdh"_L1)) {
ciphers << ciph; ciphers << ciph;
if (ciph.usedBits() >= 128) if (ciph.usedBits() >= 128)
@ -104,7 +106,7 @@ QString QTlsBackendOpenSSL::getErrorsFromOpenSsl()
unsigned long errNum; unsigned long errNum;
while ((errNum = q_ERR_get_error())) { while ((errNum = q_ERR_get_error())) {
if (!errorString.isEmpty()) if (!errorString.isEmpty())
errorString.append(QLatin1String(", ")); errorString.append(", "_L1);
q_ERR_error_string_n(errNum, buf, sizeof buf); q_ERR_error_string_n(errNum, buf, sizeof buf);
errorString.append(QString::fromLatin1(buf)); // error is ascii according to man ERR_error_string errorString.append(QString::fromLatin1(buf)); // error is ascii according to man ERR_error_string
} }
@ -226,7 +228,7 @@ void QTlsBackendOpenSSL::ensureCiphersAndCertsLoaded() const
// check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there) // check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there)
const QList<QByteArray> dirs = QSslSocketPrivate::unixRootCertDirectories(); const QList<QByteArray> dirs = QSslSocketPrivate::unixRootCertDirectories();
QStringList symLinkFilter; QStringList symLinkFilter;
symLinkFilter << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]"); symLinkFilter << "[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]"_L1;
for (const auto &dir : dirs) { for (const auto &dir : dirs) {
QDirIterator iterator(QLatin1String(dir), symLinkFilter, QDir::Files); QDirIterator iterator(QLatin1String(dir), symLinkFilter, QDir::Files);
if (iterator.hasNext()) { if (iterator.hasNext()) {

View File

@ -57,6 +57,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace QTlsPrivate { namespace QTlsPrivate {
namespace { namespace {
@ -305,9 +307,9 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
if (!basic) if (!basic)
return {}; return {};
QVariantMap result; QVariantMap result;
result[QLatin1String("ca")] = basic->ca ? true : false; result["ca"_L1] = basic->ca ? true : false;
if (basic->pathlen) if (basic->pathlen)
result[QLatin1String("pathLenConstraint")] = (qlonglong)q_ASN1_INTEGER_get(basic->pathlen); result["pathLenConstraint"_L1] = (qlonglong)q_ASN1_INTEGER_get(basic->pathlen);
q_BASIC_CONSTRAINTS_free(basic); q_BASIC_CONSTRAINTS_free(basic);
return result; return result;
@ -364,7 +366,7 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
if (auth_key->keyid) { if (auth_key->keyid) {
QByteArray keyid(reinterpret_cast<const char *>(auth_key->keyid->data), QByteArray keyid(reinterpret_cast<const char *>(auth_key->keyid->data),
auth_key->keyid->length); auth_key->keyid->length);
result[QLatin1String("keyid")] = keyid.toHex(); result["keyid"_L1] = keyid.toHex();
} }
// issuer // issuer
@ -372,7 +374,7 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
// serial // serial
if (auth_key->serial) if (auth_key->serial)
result[QLatin1String("serial")] = (qlonglong)q_ASN1_INTEGER_get(auth_key->serial); result["serial"_L1] = (qlonglong)q_ASN1_INTEGER_get(auth_key->serial);
q_AUTHORITY_KEYID_free(auth_key); q_AUTHORITY_KEYID_free(auth_key);
return result; return result;

View File

@ -161,6 +161,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_LOGGING_CATEGORY(lcTlsBackendSchannel, "qt.tlsbackend.schannel"); Q_LOGGING_CATEGORY(lcTlsBackendSchannel, "qt.tlsbackend.schannel");
// Defined in qsslsocket_qt.cpp. // Defined in qsslsocket_qt.cpp.
@ -213,7 +215,7 @@ long QSchannelBackend::tlsLibraryVersionNumber() const
QString QSchannelBackend::tlsLibraryVersionString() const QString QSchannelBackend::tlsLibraryVersionString() const
{ {
const auto os = QOperatingSystemVersion::current(); const auto os = QOperatingSystemVersion::current();
return QLatin1String("Secure Channel, %1 %2.%3.%4") return "Secure Channel, %1 %2.%3.%4"_L1
.arg(os.name(), .arg(os.name(),
QString::number(os.majorVersion()), QString::number(os.majorVersion()),
QString::number(os.minorVersion()), QString::number(os.minorVersion()),
@ -227,7 +229,7 @@ long QSchannelBackend::tlsLibraryBuildVersionNumber() const
QString QSchannelBackend::tlsLibraryBuildVersionString() const QString QSchannelBackend::tlsLibraryBuildVersionString() const
{ {
return QLatin1String("Secure Channel (NTDDI: 0x%1)") return "Secure Channel (NTDDI: 0x%1)"_L1
.arg(QString::number(NTDDI_VERSION, 16).toUpper()); .arg(QString::number(NTDDI_VERSION, 16).toUpper());
} }
@ -571,11 +573,11 @@ bool isCertificateAuthority(const QList<QSslCertificateExtension> &extensions)
{ {
auto it = std::find_if(extensions.cbegin(), extensions.cend(), auto it = std::find_if(extensions.cbegin(), extensions.cend(),
[](const QSslCertificateExtension &extension) { [](const QSslCertificateExtension &extension) {
return extension.name() == QLatin1String("basicConstraints"); return extension.name() == "basicConstraints"_L1;
}); });
if (it != extensions.cend()) { if (it != extensions.cend()) {
QVariantMap basicConstraints = it->value().toMap(); QVariantMap basicConstraints = it->value().toMap();
return basicConstraints.value(QLatin1String("ca"), false).toBool(); return basicConstraints.value("ca"_L1, false).toBool();
} }
return false; return false;
} }
@ -2245,7 +2247,7 @@ bool TlsCryptographSchannel::verifyCertContext(CERT_CONTEXT *certContext)
if (element->TrustStatus.dwErrorStatus & CERT_TRUST_INVALID_BASIC_CONSTRAINTS) { if (element->TrustStatus.dwErrorStatus & CERT_TRUST_INVALID_BASIC_CONSTRAINTS) {
auto it = std::find_if(extensions.cbegin(), extensions.cend(), auto it = std::find_if(extensions.cbegin(), extensions.cend(),
[](const QSslCertificateExtension &extension) { [](const QSslCertificateExtension &extension) {
return extension.name() == QLatin1String("basicConstraints"); return extension.name() == "basicConstraints"_L1;
}); });
if (it != extensions.cend()) { if (it != extensions.cend()) {
// @Note: This is actually one of two errors: // @Note: This is actually one of two errors:
@ -2253,7 +2255,7 @@ bool TlsCryptographSchannel::verifyCertContext(CERT_CONTEXT *certContext)
// or the chain path length has been exceeded." // or the chain path length has been exceeded."
QVariantMap basicConstraints = it->value().toMap(); QVariantMap basicConstraints = it->value().toMap();
QSslError error; QSslError error;
if (i > 0 && !basicConstraints.value(QLatin1String("ca"), false).toBool()) if (i > 0 && !basicConstraints.value("ca"_L1, false).toBool())
error = QSslError(QSslError::InvalidPurpose, certificate); error = QSslError(QSslError::InvalidPurpose, certificate);
else else
error = QSslError(QSslError::PathLengthExceeded, certificate); error = QSslError(QSslError::PathLengthExceeded, certificate);

View File

@ -76,6 +76,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
// Defined in qsslsocket_qt.cpp. // Defined in qsslsocket_qt.cpp.
QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key, QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key,
const QString &passPhrase); const QString &passPhrase);
@ -120,7 +122,7 @@ EphemeralSecKeychain::EphemeralSecKeychain()
const auto uuidAsString = QLatin1String(uuidAsByteArray.data(), uuidAsByteArray.size()).mid(1, uuidAsByteArray.size() - 2); const auto uuidAsString = QLatin1String(uuidAsByteArray.data(), uuidAsByteArray.size()).mid(1, uuidAsByteArray.size() - 2);
const QString keychainName const QString keychainName
= QDir::tempPath() + QDir::separator() + uuidAsString + QLatin1String(".keychain"); = QDir::tempPath() + QDir::separator() + uuidAsString + ".keychain"_L1;
// SecKeychainCreate, pathName parameter: // SecKeychainCreate, pathName parameter:
// //
// "A constant character string representing the POSIX path indicating where // "A constant character string representing the POSIX path indicating where
@ -575,107 +577,107 @@ void TlsCryptographSecureTransport::transmit()
SSLCipherSuite TlsCryptographSecureTransport::SSLCipherSuite_from_QSslCipher(const QSslCipher &ciph) SSLCipherSuite TlsCryptographSecureTransport::SSLCipherSuite_from_QSslCipher(const QSslCipher &ciph)
{ {
if (ciph.name() == QLatin1String("AES128-SHA")) if (ciph.name() == "AES128-SHA"_L1)
return TLS_RSA_WITH_AES_128_CBC_SHA; return TLS_RSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("DHE-RSA-AES128-SHA")) if (ciph.name() == "DHE-RSA-AES128-SHA"_L1)
return TLS_DHE_RSA_WITH_AES_128_CBC_SHA; return TLS_DHE_RSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("AES256-SHA")) if (ciph.name() == "AES256-SHA"_L1)
return TLS_RSA_WITH_AES_256_CBC_SHA; return TLS_RSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("DHE-RSA-AES256-SHA")) if (ciph.name() == "DHE-RSA-AES256-SHA"_L1)
return TLS_DHE_RSA_WITH_AES_256_CBC_SHA; return TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-NULL-SHA")) if (ciph.name() == "ECDH-ECDSA-NULL-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_NULL_SHA; return TLS_ECDH_ECDSA_WITH_NULL_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-RC4-SHA")) if (ciph.name() == "ECDH-ECDSA-RC4-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_RC4_128_SHA; return TLS_ECDH_ECDSA_WITH_RC4_128_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-DES-CBC3-SHA")) if (ciph.name() == "ECDH-ECDSA-DES-CBC3-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA; return TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES128-SHA")) if (ciph.name() == "ECDH-ECDSA-AES128-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA; return TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES256-SHA")) if (ciph.name() == "ECDH-ECDSA-AES256-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA; return TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-RC4-SHA")) if (ciph.name() == "ECDH-ECDSA-RC4-SHA"_L1)
return TLS_ECDHE_ECDSA_WITH_RC4_128_SHA; return TLS_ECDHE_ECDSA_WITH_RC4_128_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-DES-CBC3-SHA")) if (ciph.name() == "ECDH-ECDSA-DES-CBC3-SHA"_L1)
return TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA; return TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES128-SHA")) if (ciph.name() == "ECDH-ECDSA-AES128-SHA"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA; return TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES256-SHA")) if (ciph.name() == "ECDH-ECDSA-AES256-SHA"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA; return TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-NULL-SHA")) if (ciph.name() == "ECDH-RSA-NULL-SHA"_L1)
return TLS_ECDH_RSA_WITH_NULL_SHA; return TLS_ECDH_RSA_WITH_NULL_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-RC4-SHA")) if (ciph.name() == "ECDH-RSA-RC4-SHA"_L1)
return TLS_ECDH_RSA_WITH_RC4_128_SHA; return TLS_ECDH_RSA_WITH_RC4_128_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-DES-CBC3-SHA")) if (ciph.name() == "ECDH-RSA-DES-CBC3-SHA"_L1)
return TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA; return TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-AES128-SHA")) if (ciph.name() == "ECDH-RSA-AES128-SHA"_L1)
return TLS_ECDH_RSA_WITH_AES_128_CBC_SHA; return TLS_ECDH_RSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-AES256-SHA")) if (ciph.name() == "ECDH-RSA-AES256-SHA"_L1)
return TLS_ECDH_RSA_WITH_AES_256_CBC_SHA; return TLS_ECDH_RSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-RC4-SHA")) if (ciph.name() == "ECDH-RSA-RC4-SHA"_L1)
return TLS_ECDHE_RSA_WITH_RC4_128_SHA; return TLS_ECDHE_RSA_WITH_RC4_128_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-DES-CBC3-SHA")) if (ciph.name() == "ECDH-RSA-DES-CBC3-SHA"_L1)
return TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA; return TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-AES128-SHA")) if (ciph.name() == "ECDH-RSA-AES128-SHA"_L1)
return TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA; return TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-AES256-SHA")) if (ciph.name() == "ECDH-RSA-AES256-SHA"_L1)
return TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA; return TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("DES-CBC3-SHA")) if (ciph.name() == "DES-CBC3-SHA"_L1)
return TLS_RSA_WITH_3DES_EDE_CBC_SHA; return TLS_RSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("AES128-SHA256")) if (ciph.name() == "AES128-SHA256"_L1)
return TLS_RSA_WITH_AES_128_CBC_SHA256; return TLS_RSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("AES256-SHA256")) if (ciph.name() == "AES256-SHA256"_L1)
return TLS_RSA_WITH_AES_256_CBC_SHA256; return TLS_RSA_WITH_AES_256_CBC_SHA256;
if (ciph.name() == QLatin1String("DHE-RSA-DES-CBC3-SHA")) if (ciph.name() == "DHE-RSA-DES-CBC3-SHA"_L1)
return TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA; return TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("DHE-RSA-AES128-SHA256")) if (ciph.name() == "DHE-RSA-AES128-SHA256"_L1)
return TLS_DHE_RSA_WITH_AES_128_CBC_SHA256; return TLS_DHE_RSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("DHE-RSA-AES256-SHA256")) if (ciph.name() == "DHE-RSA-AES256-SHA256"_L1)
return TLS_DHE_RSA_WITH_AES_256_CBC_SHA256; return TLS_DHE_RSA_WITH_AES_256_CBC_SHA256;
if (ciph.name() == QLatin1String("AES256-GCM-SHA384")) if (ciph.name() == "AES256-GCM-SHA384"_L1)
return TLS_RSA_WITH_AES_256_GCM_SHA384; return TLS_RSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-AES128-SHA256")) if (ciph.name() == "ECDHE-ECDSA-AES128-SHA256"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256; return TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-AES256-SHA384")) if (ciph.name() == "ECDHE-ECDSA-AES256-SHA384"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384; return TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES128-SHA256")) if (ciph.name() == "ECDH-ECDSA-AES128-SHA256"_L1)
return TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256; return TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES256-SHA384")) if (ciph.name() == "ECDH-ECDSA-AES256-SHA384"_L1)
return TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384; return TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES128-SHA256")) if (ciph.name() == "ECDHE-RSA-AES128-SHA256"_L1)
return TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256; return TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES256-SHA384")) if (ciph.name() == "ECDHE-RSA-AES256-SHA384"_L1)
return TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384; return TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES256-SHA384")) if (ciph.name() == "ECDHE-RSA-AES256-SHA384"_L1)
return TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256; return TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES256-GCM-SHA384")) if (ciph.name() == "ECDHE-RSA-AES256-GCM-SHA384"_L1)
return TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384; return TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("AES128-GCM-SHA256")) if (ciph.name() == "AES128-GCM-SHA256"_L1)
return TLS_AES_128_GCM_SHA256; return TLS_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("AES256-GCM-SHA384")) if (ciph.name() == "AES256-GCM-SHA384"_L1)
return TLS_AES_256_GCM_SHA384; return TLS_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("CHACHA20-POLY1305-SHA256")) if (ciph.name() == "CHACHA20-POLY1305-SHA256"_L1)
return TLS_CHACHA20_POLY1305_SHA256; return TLS_CHACHA20_POLY1305_SHA256;
if (ciph.name() == QLatin1String("AES128-CCM-SHA256")) if (ciph.name() == "AES128-CCM-SHA256"_L1)
return TLS_AES_128_CCM_SHA256; return TLS_AES_128_CCM_SHA256;
if (ciph.name() == QLatin1String("AES128-CCM8-SHA256")) if (ciph.name() == "AES128-CCM8-SHA256"_L1)
return TLS_AES_128_CCM_8_SHA256; return TLS_AES_128_CCM_8_SHA256;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-AES128-GCM-SHA256")) if (ciph.name() == "ECDHE-ECDSA-AES128-GCM-SHA256"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256; return TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-AES256-GCM-SHA384")) if (ciph.name() == "ECDHE-ECDSA-AES256-GCM-SHA384"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384; return TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES128-GCM-SHA256")) if (ciph.name() == "ECDH-ECDSA-AES128-GCM-SHA256"_L1)
return TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256; return TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES256-GCM-SHA384")) if (ciph.name() == "ECDH-ECDSA-AES256-GCM-SHA384"_L1)
return TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384; return TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES128-GCM-SHA256")) if (ciph.name() == "ECDHE-RSA-AES128-GCM-SHA256"_L1)
return TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256; return TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("ECDH-RSA-AES128-GCM-SHA256")) if (ciph.name() == "ECDH-RSA-AES128-GCM-SHA256"_L1)
return TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256; return TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("ECDH-RSA-AES256-GCM-SHA384")) if (ciph.name() == "ECDH-RSA-AES256-GCM-SHA384"_L1)
return TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384; return TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("ECDHE-RSA-CHACHA20-POLY1305-SHA256")) if (ciph.name() == "ECDHE-RSA-CHACHA20-POLY1305-SHA256"_L1)
return TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256; return TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-CHACHA20-POLY1305-SHA256")) if (ciph.name() == "ECDHE-ECDSA-CHACHA20-POLY1305-SHA256"_L1)
return TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256; return TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256;
return 0; return 0;

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_GLOBAL_STATIC(QRecursiveMutex, qt_securetransport_mutex) Q_GLOBAL_STATIC(QRecursiveMutex, qt_securetransport_mutex)
Q_LOGGING_CATEGORY(lcSecureTransport, "qt.tlsbackend.securetransport"); Q_LOGGING_CATEGORY(lcSecureTransport, "qt.tlsbackend.securetransport");
@ -64,98 +66,98 @@ QSslCipher QSslCipher_from_SSLCipherSuite(SSLCipherSuite cipher)
// Sorted as in CipherSuite.h (and groupped by their RFC) // Sorted as in CipherSuite.h (and groupped by their RFC)
// TLS addenda using AES, per RFC 3268 // TLS addenda using AES, per RFC 3268
case TLS_RSA_WITH_AES_128_CBC_SHA: case TLS_RSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("AES128-SHA"); name = "AES128-SHA"_L1;
break; break;
case TLS_DHE_RSA_WITH_AES_128_CBC_SHA: case TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("DHE-RSA-AES128-SHA"); name = "DHE-RSA-AES128-SHA"_L1;
break; break;
case TLS_RSA_WITH_AES_256_CBC_SHA: case TLS_RSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("AES256-SHA"); name = "AES256-SHA"_L1;
break; break;
case TLS_DHE_RSA_WITH_AES_256_CBC_SHA: case TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("DHE-RSA-AES256-SHA"); name = "DHE-RSA-AES256-SHA"_L1;
break; break;
// ECDSA addenda, RFC 4492 // ECDSA addenda, RFC 4492
case TLS_ECDH_ECDSA_WITH_NULL_SHA: case TLS_ECDH_ECDSA_WITH_NULL_SHA:
name = QLatin1String("ECDH-ECDSA-NULL-SHA"); name = "ECDH-ECDSA-NULL-SHA"_L1;
break; break;
case TLS_ECDH_ECDSA_WITH_RC4_128_SHA: case TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
name = QLatin1String("ECDH-ECDSA-RC4-SHA"); name = "ECDH-ECDSA-RC4-SHA"_L1;
break; break;
case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA: case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("ECDH-ECDSA-DES-CBC3-SHA"); name = "ECDH-ECDSA-DES-CBC3-SHA"_L1;
break; break;
case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA: case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("ECDH-ECDSA-AES128-SHA"); name = "ECDH-ECDSA-AES128-SHA"_L1;
break; break;
case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA: case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("ECDH-ECDSA-AES256-SHA"); name = "ECDH-ECDSA-AES256-SHA"_L1;
break; break;
case TLS_ECDHE_ECDSA_WITH_NULL_SHA: case TLS_ECDHE_ECDSA_WITH_NULL_SHA:
name = QLatin1String("ECDHE-ECDSA-NULL-SHA"); name = "ECDHE-ECDSA-NULL-SHA"_L1;
break; break;
case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA: case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
name = QLatin1String("ECDHE-ECDSA-RC4-SHA"); name = "ECDHE-ECDSA-RC4-SHA"_L1;
break; break;
case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA: case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("ECDHE-ECDSA-DES-CBC3-SHA"); name = "ECDHE-ECDSA-DES-CBC3-SHA"_L1;
break; break;
case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("ECDHE-ECDSA-AES128-SHA"); name = "ECDHE-ECDSA-AES128-SHA"_L1;
break; break;
case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("ECDHE-ECDSA-AES256-SHA"); name = "ECDHE-ECDSA-AES256-SHA"_L1;
break; break;
case TLS_ECDH_RSA_WITH_NULL_SHA: case TLS_ECDH_RSA_WITH_NULL_SHA:
name = QLatin1String("ECDH-RSA-NULL-SHA"); name = "ECDH-RSA-NULL-SHA"_L1;
break; break;
case TLS_ECDH_RSA_WITH_RC4_128_SHA: case TLS_ECDH_RSA_WITH_RC4_128_SHA:
name = QLatin1String("ECDH-RSA-RC4-SHA"); name = "ECDH-RSA-RC4-SHA"_L1;
break; break;
case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA: case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("ECDH-RSA-DES-CBC3-SHA"); name = "ECDH-RSA-DES-CBC3-SHA"_L1;
break; break;
case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA: case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("ECDH-RSA-AES128-SHA"); name = "ECDH-RSA-AES128-SHA"_L1;
break; break;
case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA: case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("ECDH-RSA-AES256-SHA"); name = "ECDH-RSA-AES256-SHA"_L1;
break; break;
case TLS_ECDHE_RSA_WITH_NULL_SHA: case TLS_ECDHE_RSA_WITH_NULL_SHA:
name = QLatin1String("ECDHE-RSA-NULL-SHA"); name = "ECDHE-RSA-NULL-SHA"_L1;
break; break;
case TLS_ECDHE_RSA_WITH_RC4_128_SHA: case TLS_ECDHE_RSA_WITH_RC4_128_SHA:
name = QLatin1String("ECDHE-RSA-RC4-SHA"); name = "ECDHE-RSA-RC4-SHA"_L1;
break; break;
case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("ECDHE-RSA-DES-CBC3-SHA"); name = "ECDHE-RSA-DES-CBC3-SHA"_L1;
break; break;
case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("ECDHE-RSA-AES128-SHA"); name = "ECDHE-RSA-AES128-SHA"_L1;
break; break;
case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("ECDHE-RSA-AES256-SHA"); name = "ECDHE-RSA-AES256-SHA"_L1;
break; break;
// TLS 1.2 addenda, RFC 5246 // TLS 1.2 addenda, RFC 5246
case TLS_RSA_WITH_3DES_EDE_CBC_SHA: case TLS_RSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("DES-CBC3-SHA"); name = "DES-CBC3-SHA"_L1;
break; break;
case TLS_RSA_WITH_AES_128_CBC_SHA256: case TLS_RSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("AES128-SHA256"); name = "AES128-SHA256"_L1;
break; break;
case TLS_RSA_WITH_AES_256_CBC_SHA256: case TLS_RSA_WITH_AES_256_CBC_SHA256:
name = QLatin1String("AES256-SHA256"); name = "AES256-SHA256"_L1;
break; break;
case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA: case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("DHE-RSA-DES-CBC3-SHA"); name = "DHE-RSA-DES-CBC3-SHA"_L1;
break; break;
case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256: case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("DHE-RSA-AES128-SHA256"); name = "DHE-RSA-AES128-SHA256"_L1;
break; break;
case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256: case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
name = QLatin1String("DHE-RSA-AES256-SHA256"); name = "DHE-RSA-AES256-SHA256"_L1;
break; break;
// Addendum from RFC 4279, TLS PSK // Addendum from RFC 4279, TLS PSK
@ -166,7 +168,7 @@ QSslCipher QSslCipher_from_SSLCipherSuite(SSLCipherSuite cipher)
// Addenda from rfc 5288 AES Galois Counter Mode (CGM) Cipher Suites for TLS // Addenda from rfc 5288 AES Galois Counter Mode (CGM) Cipher Suites for TLS
case TLS_RSA_WITH_AES_256_GCM_SHA384: case TLS_RSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("AES256-GCM-SHA384"); name = "AES256-GCM-SHA384"_L1;
break; break;
// RFC 5487 - PSK with SHA-256/384 and AES GCM // RFC 5487 - PSK with SHA-256/384 and AES GCM
@ -174,90 +176,90 @@ QSslCipher QSslCipher_from_SSLCipherSuite(SSLCipherSuite cipher)
// Addenda from rfc 5289 Elliptic Curve Cipher Suites with HMAC SHA-256/384 // Addenda from rfc 5289 Elliptic Curve Cipher Suites with HMAC SHA-256/384
case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("ECDHE-ECDSA-AES128-SHA256"); name = "ECDHE-ECDSA-AES128-SHA256"_L1;
break; break;
case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384: case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
name = QLatin1String("ECDHE-ECDSA-AES256-SHA384"); name = "ECDHE-ECDSA-AES256-SHA384"_L1;
break; break;
case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256: case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("ECDH-ECDSA-AES128-SHA256"); name = "ECDH-ECDSA-AES128-SHA256"_L1;
break; break;
case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384: case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
name = QLatin1String("ECDH-ECDSA-AES256-SHA384"); name = "ECDH-ECDSA-AES256-SHA384"_L1;
break; break;
case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("ECDHE-RSA-AES128-SHA256"); name = "ECDHE-RSA-AES128-SHA256"_L1;
break; break;
case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384: case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
name = QLatin1String("ECDHE-RSA-AES256-SHA384"); name = "ECDHE-RSA-AES256-SHA384"_L1;
break; break;
case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256: case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("ECDH-RSA-AES128-SHA256"); name = "ECDH-RSA-AES128-SHA256"_L1;
break; break;
case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384: case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
name = QLatin1String("ECDH-RSA-AES256-SHA384"); name = "ECDH-RSA-AES256-SHA384"_L1;
break; break;
// Addenda from rfc 5289 Elliptic Curve Cipher Suites // Addenda from rfc 5289 Elliptic Curve Cipher Suites
// with SHA-256/384 and AES Galois Counter Mode (GCM) // with SHA-256/384 and AES Galois Counter Mode (GCM)
case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("ECDHE-RSA-AES256-GCM-SHA384"); name = "ECDHE-RSA-AES256-GCM-SHA384"_L1;
break; break;
// TLS 1.3 standard cipher suites for ChaCha20+Poly1305. // TLS 1.3 standard cipher suites for ChaCha20+Poly1305.
// Note: TLS 1.3 ciphersuites do not specify the key exchange // Note: TLS 1.3 ciphersuites do not specify the key exchange
// algorithm -- they only specify the symmetric ciphers. // algorithm -- they only specify the symmetric ciphers.
case TLS_AES_128_GCM_SHA256: case TLS_AES_128_GCM_SHA256:
name = QLatin1String("AES128-GCM-SHA256"); name = "AES128-GCM-SHA256"_L1;
break; break;
case TLS_AES_256_GCM_SHA384: case TLS_AES_256_GCM_SHA384:
name = QLatin1String("AES256-GCM-SHA384"); name = "AES256-GCM-SHA384"_L1;
break; break;
case TLS_CHACHA20_POLY1305_SHA256: case TLS_CHACHA20_POLY1305_SHA256:
name = QLatin1String("CHACHA20-POLY1305-SHA256"); name = "CHACHA20-POLY1305-SHA256"_L1;
break; break;
case TLS_AES_128_CCM_SHA256: case TLS_AES_128_CCM_SHA256:
name = QLatin1String("AES128-CCM-SHA256"); name = "AES128-CCM-SHA256"_L1;
break; break;
case TLS_AES_128_CCM_8_SHA256: case TLS_AES_128_CCM_8_SHA256:
name = QLatin1String("AES128-CCM8-SHA256"); name = "AES128-CCM8-SHA256"_L1;
break; break;
// Addenda from rfc 5289 Elliptic Curve Cipher Suites with // Addenda from rfc 5289 Elliptic Curve Cipher Suites with
// SHA-256/384 and AES Galois Counter Mode (GCM). // SHA-256/384 and AES Galois Counter Mode (GCM).
case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
name = QLatin1String("ECDHE-ECDSA-AES128-GCM-SHA256"); name = "ECDHE-ECDSA-AES128-GCM-SHA256"_L1;
break; break;
case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("ECDHE-ECDSA-AES256-GCM-SHA384"); name = "ECDHE-ECDSA-AES256-GCM-SHA384"_L1;
break; break;
case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256: case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
name = QLatin1String("ECDH-ECDSA-AES128-GCM-SHA256"); name = "ECDH-ECDSA-AES128-GCM-SHA256"_L1;
break; break;
case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384: case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("ECDH-ECDSA-AES256-GCM-SHA384"); name = "ECDH-ECDSA-AES256-GCM-SHA384"_L1;
break; break;
case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
name = QLatin1String("ECDHE-RSA-AES128-GCM-SHA256"); name = "ECDHE-RSA-AES128-GCM-SHA256"_L1;
break; break;
case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256: case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
name = QLatin1String("ECDH-RSA-AES128-GCM-SHA256"); name = "ECDH-RSA-AES128-GCM-SHA256"_L1;
break; break;
case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384: case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("ECDH-RSA-AES256-GCM-SHA384"); name = "ECDH-RSA-AES256-GCM-SHA384"_L1;
break; break;
// Addenda from rfc 7905 ChaCha20-Poly1305 Cipher Suites for // Addenda from rfc 7905 ChaCha20-Poly1305 Cipher Suites for
// Transport Layer Security (TLS). // Transport Layer Security (TLS).
case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
name = QLatin1String("ECDHE-RSA-CHACHA20-POLY1305-SHA256"); name = "ECDHE-RSA-CHACHA20-POLY1305-SHA256"_L1;
break; break;
case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
name = QLatin1String("ECDHE-ECDSA-CHACHA20-POLY1305-SHA256"); name = "ECDHE-ECDSA-CHACHA20-POLY1305-SHA256"_L1;
break; break;
default: default:
return {}; return {};
} }
return QTlsBackend::createCiphersuite(name, QSsl::TlsV1_2, QLatin1String("TLSv1.2")); return QTlsBackend::createCiphersuite(name, QSsl::TlsV1_2, "TLSv1.2"_L1);
} }
} // namespace QTlsPrivate } // namespace QTlsPrivate
@ -266,7 +268,7 @@ bool QSecureTransportBackend::s_loadedCiphersAndCerts = false;
QString QSecureTransportBackend::tlsLibraryVersionString() const QString QSecureTransportBackend::tlsLibraryVersionString() const
{ {
return QLatin1String("Secure Transport, ") + QSysInfo::prettyProductName(); return "Secure Transport, "_L1 + QSysInfo::prettyProductName();
} }
QString QSecureTransportBackend::tlsLibraryBuildVersionString() const QString QSecureTransportBackend::tlsLibraryBuildVersionString() const

View File

@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace QTlsPrivate { namespace QTlsPrivate {
namespace { namespace {
@ -291,7 +293,7 @@ bool X509CertificateGeneric::parse(const QByteArray &data)
if (!parseExtension(elem.value(), extension)) if (!parseExtension(elem.value(), extension))
return false; return false;
if (extension.oid == QLatin1String("2.5.29.17")) { if (extension.oid == "2.5.29.17"_L1) {
// subjectAltName // subjectAltName
// Note, parseExtension() returns true for this extensions, // Note, parseExtension() returns true for this extensions,