diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qnetworkreply.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qhostaddress.cpp | 36 | ||||
-rw-r--r-- | src/network/kernel/qnetworkproxy_mac.cpp | 15 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 3 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 3 |
5 files changed, 40 insertions, 19 deletions
diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index d9b3acdd92..1710af723f 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -606,7 +606,7 @@ QList<QByteArray> QNetworkReply::rawHeaderList() const /*! Returns the attribute associated with the code \a code. If the - attribute has not been set, it returns an invalid QVariant (type QMetaType::Unknown). + attribute has not been set, it returns an invalid QVariant (type QMetaType::UnknownType). You can expect the default values listed in QNetworkRequest::Attribute to be applied to the values returned by diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 10fdf2f97d..b68f6adfff 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -778,18 +778,34 @@ bool QHostAddress::operator==(const QHostAddress &other) const bool QHostAddress::operator ==(SpecialAddress other) const { QT_ENSURE_PARSED(this); - QHostAddress otherAddress(other); - QT_ENSURE_PARSED(&otherAddress); + switch (other) { + case Null: + return d->protocol == QAbstractSocket::UnknownNetworkLayerProtocol; - if (d->protocol == QAbstractSocket::IPv4Protocol) - return otherAddress.d->protocol == QAbstractSocket::IPv4Protocol && d->a == otherAddress.d->a; - if (d->protocol == QAbstractSocket::IPv6Protocol) { - return otherAddress.d->protocol == QAbstractSocket::IPv6Protocol - && memcmp(&d->a6, &otherAddress.d->a6, sizeof(Q_IPV6ADDR)) == 0; + case Broadcast: + return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_BROADCAST; + + case LocalHost: + return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_LOOPBACK; + + case Any: + return d->protocol == QAbstractSocket::AnyIPProtocol; + + case AnyIPv4: + return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_ANY; + + case LocalHostIPv6: + case AnyIPv6: + if (d->protocol == QAbstractSocket::IPv6Protocol) { + Q_IPV6ADDR ip6 = { { 0 } }; + ip6[15] = quint8(other == LocalHostIPv6); // 1 for localhost, 0 for any + return memcmp(&d->a6, &ip6, sizeof ip6) == 0; + } + return false; } - if (d->protocol == QAbstractSocket::AnyIPProtocol) - return other == QHostAddress::Any; - return int(other) == int(Null); + + Q_UNREACHABLE(); + return false; } /*! diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp index 7d262467c3..a1ac349949 100644 --- a/src/network/kernel/qnetworkproxy_mac.cpp +++ b/src/network/kernel/qnetworkproxy_mac.cpp @@ -221,18 +221,29 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query) int enabled; if (CFNumberGetValue(pacEnabled, kCFNumberIntType, &enabled) && enabled) { // PAC is enabled - CFStringRef cfPacLocation = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString); + // kSCPropNetProxiesProxyAutoConfigURLString returns the URL string + // as entered in the system proxy configuration dialog + CFStringRef pacLocationSetting = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString); + QCFType<CFStringRef> cfPacLocation = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, pacLocationSetting, NULL, NULL, + kCFStringEncodingUTF8); if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { QCFType<CFDataRef> pacData; QCFType<CFURLRef> pacUrl = CFURLCreateWithString(kCFAllocatorDefault, cfPacLocation, NULL); + if (!pacUrl) { + qWarning("Invalid PAC URL \"%s\"", qPrintable(QCFString::toQString(cfPacLocation))); + return result; + } SInt32 errorCode; if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, pacUrl, &pacData, NULL, NULL, &errorCode)) { QString pacLocation = QCFString::toQString(cfPacLocation); qWarning("Unable to get the PAC script at \"%s\" (%s)", qPrintable(pacLocation), cfurlErrorDescription(errorCode)); return result; } - + if (!pacData) { + qWarning("\"%s\" returned an empty PAC script", qPrintable(QCFString::toQString(cfPacLocation))); + return result; + } QCFType<CFStringRef> pacScript = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, pacData, kCFStringEncodingISOLatin1); if (!pacScript) { // This should never happen, but the documentation says it may return NULL if there was a problem creating the object. diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index ad170e187c..eed1b70025 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -567,9 +567,6 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16 return false; } - localPort = port; - localAddress = address; - #if defined (QNATIVESOCKETENGINE_DEBUG) qDebug("QNativeSocketEnginePrivate::nativeBind(%s, %i) == true", address.toString().toLatin1().constData(), port); diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index f5943d657f..184add15c3 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -852,9 +852,6 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port) return false; } - localPort = port; - localAddress = address; - #if defined (QNATIVESOCKETENGINE_DEBUG) qDebug("QNativeSocketEnginePrivate::nativeBind(%s, %i) == true", address.toString().toLatin1().constData(), port); |