[issue3073] Cookie.Morsel breaks in parsing cookie values with whitespace

Lawrence Oluyede report at bugs.python.org
Tue Jun 10 12:11:44 CEST 2008


New submission from Lawrence Oluyede <l.oluyede at gmail.com>:

It seems the Cookie module has an odd behavior with whitespaces.
According to http://wp.netscape.com/newsref/std/cookie_spec.html and
http://en.wikipedia.org/wiki/HTTP_cookie#Cookie_attributes the 'Expires'
attribute of the cookie should have this format:

"Wdy, DD-Mon-YYYY HH:MM:SS GMT"

and this is recognized by all the browsers. The oddity comes when I try
to load or create a cookie with that attribute:

Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Cookie import SimpleCookie
>>> cookies = SimpleCookie()
>>> cookies.load('foo=baz; expires=Sat, 10-Jun-1978 09:41:04 GMT')
>>> cookies
<SimpleCookie: foo='baz'>
>>> cookies['foo']['expires']
'Sat,'
>>> cookies.load('foo=baz; expires=2008-06-10T09:44:45.963024')
>>> cookies['foo']['expires']
'2008-06-10T09:44:45.963024'

It really seems the parser breaks on whitespaces.

----------
components: Library (Lib)
messages: 67901
nosy: rhymes
severity: normal
status: open
title: Cookie.Morsel breaks in parsing cookie values with whitespace
type: behavior
versions: Python 2.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3073>
_______________________________________


More information about the Python-bugs-list mailing list