summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/access/qnetworkcookie.cpp2
-rw-r--r--tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp20
2 files changed, 21 insertions, 1 deletions
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 48466185d5..fed0afce12 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -931,7 +931,7 @@ QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieStrin
// When there are multiple SetCookie headers they are join with a new line
// \n will always be the start of a new cookie
- int endOfSetCookie = cookieString.indexOf('\n');
+ int endOfSetCookie = cookieString.indexOf('\n', position);
if (endOfSetCookie == -1)
endOfSetCookie = length;
diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
index 2187b61787..36a4b458dd 100644
--- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
+++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
@@ -680,6 +680,26 @@ void tst_QNetworkCookie::parseMultipleCookies_data()
list << cookie;
QTest::newRow("network1") << "id=51706646077999719 bb=\"K14144t\"_AAQ\"ototrK_A_ttot44AQ4KwoRQtoto| adv=; Domain=.bluestreak.com; expires=Tuesday 05-Dec-2017 09:11:07 GMT; path=/;" << list;
+ QNetworkCookie cookieA;
+ cookieA.setName("a");
+ cookieA.setValue("b");
+
+ QNetworkCookie cookieB;
+ cookieB.setName("c");
+ cookieB.setValue("d");
+
+ // NewLine
+ cookieA.setExpirationDate(QDateTime(QDate(2009, 3, 10), QTime(7, 0, 0, 0), Qt::UTC));
+ cookieB.setExpirationDate(QDateTime(QDate(2009, 3, 20), QTime(7, 0, 0, 0), Qt::UTC));
+ list = QList<QNetworkCookie>() << cookieA << cookieB;
+ QTest::newRow("real-0") << "a=b; expires=Tue Mar 10 07:00:00 2009 GMT\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list;
+ QTest::newRow("real-1") << "a=b; expires=Tue Mar 10 07:00:00 2009 GMT\n\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list;
+ QTest::newRow("real-2") << "a=b; expires=Mar 10 07:00:00 2009 GMT, Tue\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list;
+
+ // Match firefox's behavior
+ cookieA.setPath("/foo");
+ list = QList<QNetworkCookie>() << cookieA << cookieB;
+ QTest::newRow("real-3") << "a=b; expires=Mar 10 07:00:00 2009 GMT, Tue; path=/foo\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list;
}
void tst_QNetworkCookie::parseMultipleCookies()