summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@blackberry.com>2013-12-11 11:16:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-13 09:44:13 +0100
commit746dddeb9f95b45d23256177efe2b474ef104640 (patch)
tree92e7553cbd43a402db78d04a1daccb59fa98b7b7 /src
parent18a36fd6eccf97b46e0c28d4deaf0edb42d523fc (diff)
QNetworkCookie: allow cookies for IPv4 domains
If the domain is an IP address, we should not do any magic regarding leading dots etc. Task-number: QTBUG-35022 Change-Id: I7722de4e6027666dde27e9e37b6353e3da775d94 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qnetworkcookie.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index a871c04d56..55049280aa 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -51,6 +51,7 @@
#include "QtCore/qstring.h"
#include "QtCore/qstringlist.h"
#include "QtCore/qurl.h"
+#include "QtNetwork/qhostaddress.h"
#include "private/qobject_p.h"
QT_BEGIN_NAMESPACE
@@ -1015,14 +1016,19 @@ void QNetworkCookie::normalize(const QUrl &url)
d->path = defaultPath;
}
- if (d->domain.isEmpty())
+ if (d->domain.isEmpty()) {
d->domain = url.host();
- else if (!d->domain.startsWith(QLatin1Char('.')))
- // Ensure the domain starts with a dot if its field was not empty
- // in the HTTP header. There are some servers that forget the
- // leading dot and this is actually forbidden according to RFC 2109,
- // but all browsers accept it anyway so we do that as well.
- d->domain.prepend(QLatin1Char('.'));
+ } else {
+ QHostAddress hostAddress(d->domain);
+ if (hostAddress.protocol() != QAbstractSocket::IPv4Protocol
+ && !d->domain.startsWith(QLatin1Char('.'))) {
+ // Ensure the domain starts with a dot if its field was not empty
+ // in the HTTP header. There are some servers that forget the
+ // leading dot and this is actually forbidden according to RFC 2109,
+ // but all browsers accept it anyway so we do that as well.
+ d->domain.prepend(QLatin1Char('.'));
+ }
+ }
}
#ifndef QT_NO_DEBUG_STREAM