diff options
author | Peter Hartmann <peter.hartmann@trolltech.com> | 2009-04-30 12:35:46 (GMT) |
---|---|---|
committer | Peter Hartmann <peter.hartmann@trolltech.com> | 2009-04-30 14:44:17 (GMT) |
commit | 1a18308b311f031d001e3b3e98ffb61e840a6d8c (patch) | |
tree | db40b5f8d17c1eb3baf2932fd3148c5a6d172929 /src/network | |
parent | ea80a3dc8acdb95c0c217b3574718c88c7a36e9f (diff) | |
download | Qt-1a18308b311f031d001e3b3e98ffb61e840a6d8c.zip Qt-1a18308b311f031d001e3b3e98ffb61e840a6d8c.tar.gz Qt-1a18308b311f031d001e3b3e98ffb61e840a6d8c.tar.bz2 |
QNetworkCookieJar: allow cookies with wrong domain attribute
According to the (old) cookie RFC 2109, the domain attribute must
always contain a leading dot. Some servers do not have that, but all
browsers accept those cookies anyway, so we should do that as well.
Reviewed-by: Olivier
Reviewed-by: Denis
Task-number: 228974
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qnetworkcookie.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 01a743b..aaa5075 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -976,14 +976,14 @@ QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieStrin cookie.setExpirationDate(dt); } else if (field.first == "domain") { QByteArray rawDomain = field.second; - QString maybeLeadingDot; if (rawDomain.startsWith('.')) { - maybeLeadingDot = QLatin1Char('.'); rawDomain = rawDomain.mid(1); } - QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain))); - cookie.setDomain(maybeLeadingDot + normalizedDomain); + // always add the dot, there are some servers that forget the + // leading dot. This is actually forbidden according to RFC 2109, + // but all browsers accept it anyway so we do that as well + cookie.setDomain(QLatin1Char('.') + normalizedDomain); } else if (field.first == "max-age") { bool ok = false; int secs = field.second.toInt(&ok); @@ -1184,7 +1184,6 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieLis cookie.expirationDate() < now; // validate the cookie & set the defaults if unset - // (RFC 2965: "The request-URI MUST path-match the Path attribute of the cookie.") if (cookie.path().isEmpty()) cookie.setPath(defaultPath); else if (!isParentPath(pathAndFileName, cookie.path())) |