summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkcookie.cpp
diff options
context:
space:
mode:
authorPeter Hartmann <[email protected]>2013-11-26 13:58:47 -0500
committerThe Qt Project <[email protected]>2013-12-13 09:44:25 +0100
commitae293c1cb220847194fba6dcebdbb9194837bb56 (patch)
tree75974be031d8428fa82a98079ec519918ce9bb55 /src/network/access/qnetworkcookie.cpp
parent746dddeb9f95b45d23256177efe2b474ef104640 (diff)
QNetworkCookie: allow cookies for IPv6 domains
For IPv6 addresses don't call toAce as it returns the empty string. We should reflect the behavior of browsers here, which all accept cookies from IPv6 addresses. Original-patch-by: David Tapuska <[email protected]> Task-number: QTBUG-35022 Change-Id: Ic00369e923d044ec459822b2405865c13e4185b6 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Richard J. Moore <[email protected]>
Diffstat (limited to 'src/network/access/qnetworkcookie.cpp')
-rw-r--r--src/network/access/qnetworkcookie.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 55049280aa5..664bc8282c3 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -467,12 +467,19 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const
}
if (!d->domain.isEmpty()) {
result += "; domain=";
- QString domainNoDot = d->domain;
- if (domainNoDot.startsWith(QLatin1Char('.'))) {
+ if (d->domain.startsWith(QLatin1Char('.'))) {
result += '.';
- domainNoDot = domainNoDot.mid(1);
+ result += QUrl::toAce(d->domain.mid(1));
+ } else {
+ QHostAddress hostAddr(d->domain);
+ if (hostAddr.protocol() == QAbstractSocket::IPv6Protocol) {
+ result += '[';
+ result += d->domain.toUtf8();
+ result += ']';
+ } else {
+ result += QUrl::toAce(d->domain);
+ }
}
- result += QUrl::toAce(domainNoDot);
}
if (!d->path.isEmpty()) {
result += "; path=";
@@ -1021,6 +1028,7 @@ void QNetworkCookie::normalize(const QUrl &url)
} else {
QHostAddress hostAddress(d->domain);
if (hostAddress.protocol() != QAbstractSocket::IPv4Protocol
+ && hostAddress.protocol() != QAbstractSocket::IPv6Protocol
&& !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