New submission from Paulie Pena <paul...@gmail.com>:

Since `requests` creates a comma-separated list for any duplicated headers, 
this causes a problem when `expires=...` is between two `Set-Cookie` header 
values. `BaseCookie.__parse_string()` in 
https://github.com/python/cpython/blob/master/Lib/http/cookies.py, in that 
case, will just give up, since it thinks it was given an invalid cookie. The 
fix is to replace the comma at the end of each trailing `expires=...` with a 
semicolon. Inside `BaseCookie.__parse_string()`, before the `while` loop, all 
that should be needed is to add this:
```
str = re.sub('(=\w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT),', r'\1;', str)
```

----------
components: Library (Lib)
messages: 380294
nosy: paulie4
priority: normal
severity: normal
status: open
title: BaseCookie.__parse_string() doesn't work with expires= between cookies
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42256>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to