Commits

Ian Bicking committed 1592b7b

Catch cookie errors when parsing cookies (http://trac.pythonpaste.org/pythonpaste/ticket/189)

  • Participants
  • Parent commits 3d6112b

Comments (0)

Files changed (2)

File paste/request.py

 
 """
 import cgi
-from Cookie import SimpleCookie
+from Cookie import SimpleCookie, CookieError
 from StringIO import StringIO
 import urlparse
 import urllib
         if check_header == header:
             return cookies
     cookies = SimpleCookie()
-    cookies.load(header)
+    try:
+        cookies.load(header)
+    except CookieError:
+        pass
     environ['paste.cookies'] = (cookies, header)
     return cookies
 
         if check_header == header:
             return cookies
     cookies = SimpleCookie()
-    cookies.load(header)
+    try:
+        cookies.load(header)
+    except CookieError:
+        pass
     result = {}
     for name in cookies:
         result[name] = cookies[name].value

File tests/test_request.py

     assert get_cookie_dict(env) == {}
     env['HTTP_COOKIE'] = '=foo'
     assert get_cookie_dict(env) == {}
+    env['HTTP_COOKIE'] = '?='
+    assert get_cookie_dict(env) == {}