diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index d57acc2f6b..057821fa3f 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -71,6 +71,8 @@ #include "qthread.h" +#include + QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QNetworkAccessFileBackendFactory, fileBackend) @@ -1324,10 +1326,16 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera } #ifndef QT_NO_BEARERMANAGEMENT + // Return a disabled network reply if network access is disabled. - // Except if the scheme is empty or file://. + // Except if the scheme is empty or file:// or if the host resolves to a loopback address. if (d->networkAccessible == NotAccessible && !isLocalFile) { - return new QDisabledNetworkReply(this, req, op); + QHostAddress dest; + QString host = req.url().host().toLower(); + if (!(dest.setAddress(host) && dest.isLoopback()) && host != QLatin1String("localhost") + && host != QHostInfo::localHostName().toLower()) { + return new QDisabledNetworkReply(this, req, op); + } } if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) {