I use web.py , which internally uses cookie.SimpleCookie to load cookies coming from a user browser.
Sometimes I get exceptions like:
... File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/Cookie.py", line 455, in set raise CookieError("Illegal key value: %s" % key) CookieError: Illegal key value: SinaRot/g/news.sina.com.cn
The offensive character is apparently a slash ( / ), which, according to my reading of RFC 2109 (cookies) and RFC 2068 (HTTP 1.1) should be disabled, so OK.
I do not set this cookie, and I'm not sure why and how it is configured for my domain (perhaps a proxy server), but it does not matter; the big problem is that simplecookie fails when it encounters this cookie and returns an error to the user.
So my question is: is there a way to ask SimpleCookie just ignore invalid cookies but return the rest? I could not find anything obvious in the docs to do this.
source share