diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-11-06 12:35:46 (GMT) |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-11-09 15:01:29 (GMT) |
commit | 4454669fc238171239f8a2f202ec7e26e7409776 (patch) | |
tree | 99ce0619450409df53dcb9e479a2c634f7e405fb /tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp | |
parent | b87cc5edbf3100da062f20eefbc1fdb737b74118 (diff) | |
download | Qt-4454669fc238171239f8a2f202ec7e26e7409776.zip Qt-4454669fc238171239f8a2f202ec7e26e7409776.tar.gz Qt-4454669fc238171239f8a2f202ec7e26e7409776.tar.bz2 |
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 'tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp')
-rw-r--r-- | tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 9b9c56a..ff7e78e 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -120,7 +120,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() cookie.setName("a"); cookie.setPath("/"); - cookie.setDomain("www.foo.tld"); + cookie.setDomain(".foo.tld"); result += cookie; QTest::newRow("just-add") << preset << cookie << "http://www.foo.tld" << result << true; @@ -148,6 +148,20 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() cookie.setPath("/"); QTest::newRow("diff-path-order") << preset << cookie << "http://www.foo.tld" << result << true; + preset.clear(); + result.clear(); + QNetworkCookie finalCookie = cookie; + cookie.setDomain("foo.tld"); + finalCookie.setDomain(".foo.tld"); + result += finalCookie; + QTest::newRow("should-add-dot-prefix") << preset << cookie << "http://www.foo.tld" << result << true; + + result.clear(); + cookie.setDomain(""); + finalCookie.setDomain("www.foo.tld"); + result += finalCookie; + QTest::newRow("should-set-default-domain") << preset << cookie << "http://www.foo.tld" << result << true; + // security test: result.clear(); preset.clear(); @@ -159,7 +173,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() QTest::newRow("security-path-1") << preset << cookie << "http://www.foo.tld" << result << false; // setting the defaults: - QNetworkCookie finalCookie = cookie; + finalCookie = cookie; finalCookie.setPath("/something/"); cookie.setPath(""); cookie.setDomain(""); |