diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-11-06 13:35:46 +0100 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-11-09 16:01:29 +0100 |
commit | 4454669fc238171239f8a2f202ec7e26e7409776 (patch) | |
tree | 99ce0619450409df53dcb9e479a2c634f7e405fb /src/network/access/qnetworkcookiejar.cpp | |
parent | b87cc5edbf3100da062f20eefbc1fdb737b74118 (diff) | |
download | qt4-tools-4454669fc238171239f8a2f202ec7e26e7409776.tar.gz |
QNetworkCookie: Add the dot prefix of the domain while adding to the jar
instead than when parsing the cookie header.
This corrects the bug QT-2379, happening in the following sequence:
parseCookie -> setCookieUrl -> toRawForm -> parseCookie
where a default domain would now also have a dot prefix, and shouldn't.
QT-2379
Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network/access/qnetworkcookiejar.cpp')
-rw-r--r-- | src/network/access/qnetworkcookiejar.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index 8430966f6f..19f7217fd7 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -198,6 +198,13 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieLis if (cookie.domain().isEmpty()) { cookie.setDomain(defaultDomain); } else { + // 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. + if (!cookie.domain().startsWith(QLatin1Char('.'))) + cookie.setDomain(QLatin1Char('.') + cookie.domain()); + QString domain = cookie.domain(); if (!(isParentDomain(domain, defaultDomain) || isParentDomain(defaultDomain, domain))) { |