Patch #1117454: Remove code to special-case cookies without values
in LWPCookieJar. Backported to 2.4.
diff --git a/Lib/_LWPCookieJar.py b/Lib/_LWPCookieJar.py
index 2c8d456..25a2528 100644
--- a/Lib/_LWPCookieJar.py
+++ b/Lib/_LWPCookieJar.py
@@ -115,13 +115,6 @@
 
                 for data in split_header_words([line]):
                     name, value = data[0]
-                    # name and value are an exception here, since a plain "foo"
-                    # (with no "=", unlike "bar=foo") means a cookie with no
-                    # name and value "foo".  With all other cookie-attributes,
-                    # the situation is reversed: "foo" means an attribute named
-                    # "foo" with no value!
-                    if value is None:
-                        name, value = value, name
                     standard = {}
                     rest = {}
                     for k in boolean_attrs:
diff --git a/Lib/_MozillaCookieJar.py b/Lib/_MozillaCookieJar.py
index 0e08c09..88e8492 100644
--- a/Lib/_MozillaCookieJar.py
+++ b/Lib/_MozillaCookieJar.py
@@ -73,6 +73,9 @@
                 secure = (secure == "TRUE")
                 domain_specified = (domain_specified == "TRUE")
                 if name == "":
+                    # cookies.txt regards 'Set-Cookie: foo' as a cookie
+                    # with no name, whereas cookielib regards it as a
+                    # cookie with no value.
                     name = value
                     value = None
 
diff --git a/Lib/cookielib.py b/Lib/cookielib.py
index 49989b4..42a2513 100644
--- a/Lib/cookielib.py
+++ b/Lib/cookielib.py
@@ -451,11 +451,7 @@
             param = param.rstrip()
             if param == "": continue
             if "=" not in param:
-                if param.lower() in known_attrs:
-                    k, v = param, None
-                else:
-                    # cookie with missing value
-                    k, v = param, None
+                k, v = param, None
             else:
                 k, v = re.split(r"\s*=\s*", param, 1)
                 k = k.lstrip()
diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_cookielib.py
index 679e3aa..7828326 100644
--- a/Lib/test/test_cookielib.py
+++ b/Lib/test/test_cookielib.py
@@ -231,6 +231,24 @@
     return cookie_hdr
 
 
+class FileCookieJarTests(TestCase):
+    def test_lwp_valueless_cookie(self):
+        # cookies with no value should be saved and loaded consistently
+        from cookielib import LWPCookieJar
+        filename = test_support.TESTFN
+        c = LWPCookieJar()
+        interact_netscape(c, "http://www.acme.com/", 'boo')
+        self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
+        try:
+            c.save(filename, ignore_discard=True)
+            c = LWPCookieJar()
+            c.load(filename, ignore_discard=True)
+        finally:
+            try: os.unlink(filename)
+            except OSError: pass
+        self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
+
+
 class CookieTests(TestCase):
     # XXX
     # Get rid of string comparisons where not actually testing str / repr.
@@ -1636,6 +1654,7 @@
         DateTimeTests,
         HeaderTests,
         CookieTests,
+        FileCookieJarTests,
         LWPCookieTests,
         )