Commits

Sergey Schetinin committed 4c4bf44

explain the handling of $key=xx in cookies

Comments (0)

Files changed (2)

tests/test_cookies.py

     """
         Testing several missing features of cookies.Cookie.
             * repr version
-            * ignoring a key-value for Cookie when key == $
     """
     c = cookies.Cookie() # empty cookie
     eq_(repr(c), '<Cookie: []>')
     eq_(c.serialize(),
         'CP=null*, PHPSESSID=0a539d42abc001cdc762809248d4beed, a=42, '
         'dismiss-top=6')
-    # data with key==$
-    c = cookies.Cookie('dismiss-top=6; CP=null*; $=42'\
-                       'PHPSESSID=0a539d42abc001cdc762809248d4beed; a=42')
-    ok_('$' not in c, 'Key $ should have been ignored')
-    c = cookies.Cookie('$=a; dismiss-top=6; CP=null*; $=42'\
-                       'PHPSESSID=0a539d42abc001cdc762809248d4beed; a=42')
-    ok_('$' not in c, 'Key $ should have been ignored')
+    # reserved keys ($xx)
+    c = cookies.Cookie('dismiss-top=6; CP=null*; $version=42; a=42')
+    assert '$version' not in c
+    c = cookies.Cookie('$reserved=42; a=$42')
+    eq(c.keys(), ['a'])
 
 def test_serialize_cookie_date():
     """
                 if ckey:
                     self[ckey][key] = _unquote(val)
             elif key[0] == '$':
+                # RFC2109: NAMEs that begin with $ are reserved for other uses
+                # and must not be used by applications.
                 continue
             else:
                 self[key] = _unquote(val)