summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/access/qnetworkcookie.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index be4ea2ff36..89e6f8a5ae 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -1015,9 +1015,15 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt
} else if (field.first == "max-age") {
bool ok = false;
int secs = field.second.toInt(&ok);
- if (!ok)
- return result;
- cookie.setExpirationDate(now.addSecs(secs));
+ if (ok) {
+ if (secs <= 0) {
+ //earliest representable time (RFC6265 section 5.2.2)
+ cookie.setExpirationDate(QDateTime::fromTime_t(0));
+ } else {
+ cookie.setExpirationDate(now.addSecs(secs));
+ }
+ }
+ //if unparsed, ignore the attribute but not the whole cookie (RFC6265 section 5.2.2)
} else if (field.first == "path") {
QString path = QUrl::fromPercentEncoding(field.second);
cookie.setPath(path);