summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@nokia.com>2011-09-14 16:12:10 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-27 00:46:35 +0200
commit297a25cc4bdfb925eaaa2cc940053718a9519dae (patch)
tree7eb46f4fce68c6a51af81ef471aab91a7cace1f7 /tests/auto/network/access
parente1402c0d278b4570444e3e20b93fd5ab5619c8fc (diff)
Remove support for multiple cookies in one Set-Cookie header to follow RFC6265.
This also allows cookie values to contain commas to increase compatibility like most popular browsers do even though the RFC still reserves them for future uses. Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com> Task-number: QTBUG-21456 (cherry-picked from 8ba781b01e900148fec2e9d26485369b3295487f) Change-Id: Ib09ab2411dddf7f99de1c0c31680428b7412fc7e Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'tests/auto/network/access')
-rw-r--r--tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp54
1 files changed, 15 insertions, 39 deletions
diff --git a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
index 4df1084eac..77dfa18894 100644
--- a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
+++ b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp
@@ -181,6 +181,14 @@ void tst_QNetworkCookie::parseSingleCookie_data()
QTest::newRow("with-value-with-special4") << "a = \"\\\"\" " << cookie;
cookie.setValue("\"\\\"a, b; c\\\"\"");
QTest::newRow("with-value-with-special5") << "a = \"\\\"a, b; c\\\"\"" << cookie;
+ // RFC6265 states that cookie values shouldn't contain commas, but we still allow them
+ // since they are only reserved for future compatibility and other browsers do the same.
+ cookie.setValue(",");
+ QTest::newRow("with-value-with-special6") << "a = ," << cookie;
+ cookie.setValue(",b");
+ QTest::newRow("with-value-with-special7") << "a = ,b" << cookie;
+ cookie.setValue("b,");
+ QTest::newRow("with-value-with-special8") << "a = b," << cookie;
cookie.setValue("b c");
QTest::newRow("with-value-with-whitespace") << "a = b c" << cookie;
@@ -599,7 +607,6 @@ void tst_QNetworkCookie::parseSingleCookie()
//QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort);
QCOMPARE(result.count(), 1);
- QEXPECT_FAIL("network3", "Cookie value contains commas, violating the HTTP spec", Abort);
QCOMPARE(result.at(0), expectedCookie);
result = QNetworkCookie::parseCookies(result.at(0).toRawForm());
@@ -634,48 +641,17 @@ void tst_QNetworkCookie::parseMultipleCookies_data()
// reason: malformed NAME=VALUE pair
QTest::newRow("invalid-05") << "foo" << list;
QTest::newRow("invalid-06") << "=b" << list;
- QTest::newRow("invalid-09") << "foo,a=b" << list;
- QTest::newRow("invalid-11") << ";path=/" << list;
+ QTest::newRow("invalid-07") << ";path=/" << list;
// reason: malformed expiration date string
- QTest::newRow("invalid-12") << "a=b;expires=" << list;
- QTest::newRow("invalid-13") << "a=b;expires=foobar" << list;
- QTest::newRow("invalid-14") << "a=b;expires=foobar, abc" << list;
- QTest::newRow("invalid-15") << "a=b;expires=foobar, dd-mmm-yyyy hh:mm:ss GMT; path=/" << list;
- QTest::newRow("invalid-16") << "a=b;expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list;
-
- QNetworkCookie cookie;
- cookie.setName("a");
- list += cookie;
- cookie.setName("c");
- cookie.setValue("d");
- list += cookie;
- QTest::newRow("two-1") << "a=,c=d" << list;
- QTest::newRow("two-2") << "a=, c=d" << list;
- QTest::newRow("two-3") << "a= ,c=d" << list;
- QTest::newRow("two-4") << "a= , c=d" << list;
-
- list.clear();
- list += cookie;
- cookie.setName("a");
- cookie.setValue(QByteArray());
- list += cookie;
- QTest::newRow("two-5") << "c=d,a=" << list;
- QTest::newRow("two-6") << "c=d, a=" << list;
- QTest::newRow("two-7") << "c=d , a=" << list;
-
- cookie.setName("foo");
- cookie.setValue("bar");
- cookie.setPath("/");
- list += cookie;
- QTest::newRow("complex-1") << "c=d, a=, foo=bar; path=/" << list;
-
- cookie.setName("baz");
- cookie.setDomain(".qt.nokia.com");
- list.prepend(cookie);
- QTest::newRow("complex-2") << "baz=bar; path=/; domain=.qt.nokia.com, c=d,a=,foo=bar; path=/" << list;
+ QTest::newRow("invalid-08") << "a=b;expires=" << list;
+ QTest::newRow("invalid-09") << "a=b;expires=foobar" << list;
+ QTest::newRow("invalid-10") << "a=b;expires=foobar, abc" << list;
+ QTest::newRow("invalid-11") << "a=b;expires=foobar, dd-mmm-yyyy hh:mm:ss GMT; path=/" << list;
+ QTest::newRow("invalid-12") << "a=b;expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list;
// cookies obtained from the network:
+ QNetworkCookie cookie;
cookie = QNetworkCookie("id", "51706646077999719");
cookie.setDomain(".bluestreak.com");
cookie.setPath("/");