Title: http.cookies.SimpleCookie doesn't seem to be parsed using regulars
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: MeiK
Priority: normal Keywords: patch

Created on 2019-07-08 12:00 by MeiK, last changed 2019-07-15 20:25 by SilentGhost.

Pull Requests
URL Status Linked Edit
PR 14781 open MeiK, 2019-07-15 12:04
Messages (1)
msg347494 - (view) Author: MeiK (MeiK) * Date: 2019-07-08 12:00
In Python's built-in SimpleCookie[1], regular expressions are used to parse cookies, which seems to be a non-standard way.

I looked at the RFC documentation related to cookie resolution: rfc2109[2] and rfc6265[3], the former has been replaced by the latter. These documents stipulate that cookies should be split with a semicolon, just like http.cookiejar.parse_ns_headers[4].

But if we use the approach described in the documentation, then there will be a set of tests that fail[5].

>>> print(SimpleCookie('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"’))
Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;"

>>> print(SimpleCookie('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"’))
Set-Cookie: keebler="E=mc2

Is this a bug? Should it be modified?

English is not my native language; please excuse typing errors.

Date User Action Args
2019-07-15 20:25:11SilentGhostsetcomponents: + Library (Lib), - Extension Modules
versions: - Python 3.5, Python 3.6, Python 3.7, Python 3.8
2019-07-15 12:04:20MeiKsetkeywords: + patch
stage: patch review
pull_requests: + pull_request14577
2019-07-08 12:00:09MeiKcreate