[issue42256] BaseCookie.__parse_string() doesn't work with expires= between cookies

Paulie Pena report at bugs.python.org
Fri Apr 16 14:32:59 EDT 2021


Paulie Pena <paulie4 at gmail.com> added the comment:

Here's a simple example. This is correctly parsed via a `SimpleCookie().load()` call:
'key1=val1, key2=val2'

but this fails to parse:
'key1=val1; expires=Wed, 21 Oct 2015 07:28:00 GMT, key2=val2'

My suggested fix:
str = re.sub(r'(=\w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT),', r'\1;', str)

will convert the comma separator to a semicolon, so this will correctly parse:
'key1=val1; expires=Wed, 21 Oct 2015 07:28:00 GMT; key2=val2'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42256>
_______________________________________


More information about the Python-bugs-list mailing list