This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年01月28日 19:26 by dlamotte, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg234908 - (view) | Author: Dan LaMotte (dlamotte) | Date: 2015年01月28日 19:26 | |
I recently discovered that a valid cookie (by the RFC) is not parse-able by the Cookie library in python's standard library.
import Cookie
c = Cookie.SimpleCookie('key=[ab]cd[ef]')
print c.keys() # yields []
When quoted, it works fine:
c = Cookie.SimpleCookie('key="[ab]cd[ef]"')
print c.keys() # yields ['key']
I noticed the issue after upgrading to Python 2.7.9 (was previously at 2.7.2). The issue cropped up in our internal Django Web site when another internal site used a cookie in a similar format to the above and due to the sort order of the cookies, it appeared before the sessionid cookie we use with Django. Effectively, parsing of the cookie header stops and the sessionid is never read which ... to Django ... means you are not logged in. So, attempt to login, no errors, redirect to new page after successful login and you still appear not logged in.
References:
cookie-value in http://tools.ietf.org/html/rfc6265#section-4.1
token in http://tools.ietf.org/html/rfc2616#section-2.2
cookie-pair = cookie-name "=" cookie-value
cookie-name = token
...
The code correctly disallows brackets [ and ] in cookie-name's, but ends up disallowing them in cookie-value's as well which is not RFC Compliant.
We noticed this issue in Chrome but not Firefox. Our guess is that Firefox quotes its cookie-values which the code handles just fine.
|
|||
| msg234909 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2015年01月28日 19:42 | |
This may be a duplicate of issue 22931. If so please add your comments there and close this one. |
|||
| msg234912 - (view) | Author: Dan LaMotte (dlamotte) | Date: 2015年01月28日 20:17 | |
Yes, this is a duplicate of that bug. Sorry. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:12 | admin | set | github: 67530 |
| 2015年01月28日 20:23:56 | berker.peksag | set | superseder: cookies with square brackets in value resolution: duplicate stage: resolved |
| 2015年01月28日 20:17:22 | dlamotte | set | status: open -> closed messages: + msg234912 |
| 2015年01月28日 19:42:36 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg234909 |
| 2015年01月28日 19:26:05 | dlamotte | create | |