Bug 1549011 - Ignore cookie name-value-pair strings with an empty name; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 08 May 2019 08:51:42 +0000
changeset 534945 e8597b0c4aab785871b6a2a8b7146aec80ad91e1
parent 534944 51988a2d186aa08ab16d0ae5aa0d71bee1a7ffad
child 534946 65dd82d198821a6107fe869e0a4aee4dc3feb89f
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1549011
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549011 - Ignore cookie name-value-pair strings with an empty name; r=baku Differential Revision: https://phabricator.services.mozilla.com/D29929
netwerk/cookie/nsCookieService.cpp
netwerk/test/TestCookie.cpp
testing/web-platform/meta/cookies/http-state/chromium-tests.html.ini
testing/web-platform/meta/cookies/http-state/general-tests.html.ini
testing/web-platform/meta/cookies/http-state/mozilla-tests.html.ini
testing/web-platform/meta/cookies/http-state/name-tests.html.ini
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -3830,16 +3830,19 @@ bool nsCookieService::ParseAttributes(ns
   // note: if there's no '=', we assume token is <VALUE>. this is required by
   //       some sites (see bug 169091).
   // XXX fix the parser to parse according to <VALUE> grammar for this case
   newCookie = GetTokenValue(cookieStart, cookieEnd, tokenString, tokenValue,
                             equalsFound);
   if (equalsFound) {
     aCookieAttributes.name = tokenString;
     aCookieAttributes.value = tokenValue;
+    if (aCookieAttributes.name.IsEmpty()) {
+      aDiscard = true;
+    }
   } else {
     aDiscard = true;
   }
 
   // extract remaining attributes
   while (cookieStart != cookieEnd && !newCookie) {
     newCookie = GetTokenValue(cookieStart, cookieEnd, tokenString, tokenValue,
                               equalsFound);
--- a/netwerk/test/TestCookie.cpp
+++ b/netwerk/test/TestCookie.cpp
@@ -633,17 +633,17 @@ TEST(TestCookie, TestCookieMain)
   SetACookie(cookieService, "http://parser.test/", nullptr, "six", nullptr);
   GetACookie(cookieService, "http://parser.test/", nullptr, cookie);
   EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
   SetACookie(cookieService, "http://parser.test/", nullptr, "seven", nullptr);
   GetACookie(cookieService, "http://parser.test/", nullptr, cookie);
   EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
   SetACookie(cookieService, "http://parser.test/", nullptr, " =eight", nullptr);
   GetACookie(cookieService, "http://parser.test/", nullptr, cookie);
-  EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "eight"));
+  EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
   SetACookie(cookieService, "http://parser.test/", nullptr, "test=six",
              nullptr);
   GetACookie(cookieService, "http://parser.test/", nullptr, cookie);
   EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=six"));
 
   // *** path ordering tests
 
   // test that cookies are returned in path order - longest to shortest.
--- a/testing/web-platform/meta/cookies/http-state/chromium-tests.html.ini
+++ b/testing/web-platform/meta/cookies/http-state/chromium-tests.html.ini
@@ -1,10 +1,7 @@
 [chromium-tests.html]
   [chromium0006 - chromium0006]
     expected: FAIL
 
-  [chromium0012 - chromium0012]
-    expected: FAIL
-
   [chromium0007 - chromium0007]
     expected: FAIL
 
--- a/testing/web-platform/meta/cookies/http-state/general-tests.html.ini
+++ b/testing/web-platform/meta/cookies/http-state/general-tests.html.ini
@@ -1,7 +1,4 @@
 [general-tests.html]
-  [0021 - Ignore cookie without key in all 'Set-Cookie'.]
-    expected: FAIL
-
   [0028 - [INVALID EXPECTATION\] Ignore malformed cookies in all 'Set-Cookie' v4.]
     expected: FAIL
 
deleted file mode 100644
--- a/testing/web-platform/meta/cookies/http-state/mozilla-tests.html.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[mozilla-tests.html]
-  [mozilla0016 - mozilla0016]
-    expected: FAIL
-
-  [mozilla0017 - mozilla0017]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/cookies/http-state/name-tests.html.ini
+++ /dev/null
@@ -1,13 +0,0 @@
-[name-tests.html]
-  [name0025 - name0025]
-    expected: FAIL
-
-  [name0033 - name0033]
-    expected: FAIL
-
-  [name0028 - name0028]
-    expected: FAIL
-
-  [name0017 - name0017]
-    expected: FAIL
-