If a cookie is created with a " character in the content, the js_output which is emitted is bad javascript. eg. >>> import Cookie >>> c=Cookie.Cookie('Customer="WILE_E_COYOTE"; Version=1; Path=/acme') >>> print c Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme; Version=1 >>> print c.js_output() >>> Also, the test_cookie tests (test_load) explicitly checks for this (wrong) output. I have attached a patch that seems to fix this or at the very least produces the same Cookie settings whether the cookie is set using the header or using javascript (I've verified this on firefox on Linux).
A lot of the cookie tests need to be updated. A separate bug was filed regarding this. http://bugs.python.org/issue3788. I'm working on that now and will apply your patch there as well.
> What's wrong with < and >? >>> c=Cookie.Cookie('Customer="";'); print c.js_output() ""; // end hiding --> It allows HTML/Javascript injection. Well, Python 2.5 already displays a warning: /usr/lib/python2.5/Cookie.py:710: DeprecationWarning: Cookie/SmartCookie class is insecure; do not use it The right fix is maybe to remove deprecated and unsecure function!
Because SimpleCookie class is still usable (that is not deprecated), it makes sense to back port to Py2.7. Applied the patches in revision 71030 and r71029. Thanks.
History
Date
User
Action
Args
2022-04-11 14:56:43
admin
set
github: 49110
2009-04-02 03:04:54
orsenthil
set
status: open -> closedmessages: + versions: + Python 3.1