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.

classification
Title: http.cookies.SimpleCookie.parse could not parse cookies when one cookie value is json
Type: behavior Stage:
Components: Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder: Quote mark breaks http.cookies, Cookie.py processing
View: 27674
Assigned To: Nosy List: brayer.benoit, martin.panter
Priority: normal Keywords:

Created on 2020-09-02 16:41 by brayer.benoit, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg376253 - (view) Author: Benoît Brayer (brayer.benoit) Date: 2020-09-02 16:41
Using python3.8.5, SimpleCookie parser seems to be unable to load the cookie string when a json string is used inside one of the cookie values.

I did not try to replay using other python3 versions yet.

Please use the following code to replay the bug:

>>> from http import cookies
>>> cookie_parser = cookies.SimpleCookie()
>>> cookie_parser.load('CookieScriptConsent={"action":"accept"}; __stripe_mid=plip; __stripe_sid=plop; _ga=tada; _gcl_au=pouet; _hjid=hello; authn_token=mylogin; rememberMe=true')
>>> cookie_parser.keys()
dict_keys([])
>>> cookie_parser = cookies.SimpleCookie()
>>> cookie_parser.load('__stripe_mid=plip; __stripe_sid=plop; _ga=tada; _gcl_au=pouet; _hjid=hello; authn_token=mylogin; rememberMe=true')
>>> cookie_parser.keys()
dict_keys(['__stripe_mid', '__stripe_sid', '_ga', '_gcl_au', '_hjid', 'authn_token', 'rememberMe'])
msg376286 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2020-09-03 05:18
Perhaps this is a duplicate of Issue 27674, where I think parsing is aborted when a double-quote is seen?
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85861
2020-09-03 05:18:49martin.pantersetsuperseder: Quote mark breaks http.cookies, Cookie.py processing

messages: + msg376286
nosy: + martin.panter
2020-09-02 16:41:04brayer.benoitcreate