You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
http.cookies.SimpleCookie.parse error after [keys] or some JSON data values #86111
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2020-10-05.15:19:46.936>labels= ['type-bug', 'library', '3.10']
title='http.cookies.SimpleCookie.parse error after [keys] or some JSON data values'updated_at=<Date2022-01-04.16:01:46.232>user='https://bugs.python.org/xnovakj'
Note:
It could cause big problems with session etc.
We found that Chrome/Edge starts to save and send this type of cookies for some (couple) users. The origin of that [object Object]=... cookies are probably some implementation of https://cookiepedia.co.uk/cookies/euconsent
and errors somewhere in external javascripts or browsers?
print c
Set-Cookie: id=12345
Set-Cookie: something=not_loaded
xnovakj commented on Jan 4, 2022
xnovakjmannequin
MannequinAuthor
More actions
New examples with the structured data.
Problems are with quotes and spaces inside { or [
cookie-script.com set those cookie data:
CookieScriptConsent={"action":"accept","categories":"[\\"performance\\"]"}
Python loads only cookies before that JSON structure
>>> from http.cookies import SimpleCookie
>>> ck = SimpleCookie()
>>> ck.load('id=12345; CookieScriptConsent={"action":"accept","categories":"[\\"performance\\"]"}; something="not loaded"')
>>> print(ck)
Set-Cookie: id=12345
This works:
>>> ck.load('id=12345; complex_data={1:[1,2]}; something="loaded"')
>>> print(ck)
Set-Cookie: complex_data={1:[1,2]}
Set-Cookie: id=12345
Set-Cookie: something="loaded"
This not works:
>>> ck.load('id=12345; complex_data={1:[1, 2]}; something="not loaded"')
>>> print(ck)
Set-Cookie: complex_data={1:[1,
Set-Cookie: id=12345
Conclusion:
Parsing JSON like cookie objects works, except quotes and without spaces.
Exist some new RFC with JSON data support?
How implementation/support/solution in diferent languages?
Exist another Python library which support cookie with JSON data?
changed the title [-]http.cookies.SimpleCookie.parse error after [keys][/-][+]http.cookies.SimpleCookie.parse error after [keys] or some JSON data values[/+]on Jan 4, 2022
changed the title [-]http.cookies.SimpleCookie.parse error after [keys][/-][+]http.cookies.SimpleCookie.parse error after [keys] or some JSON data values[/+]on Jan 4, 2022
Activity
xnovakj commentedon Oct 5, 2020
If brackets [] are around cookie name,
next cookie names are not loaded.
Note:
It could cause big problems with session etc.
We found that Chrome/Edge starts to save and send this type of cookies for some (couple) users. The origin of that [object Object]=... cookies are probably some implementation of
https://cookiepedia.co.uk/cookies/euconsent
and errors somewhere in external javascripts or browsers?
Related issues:
https://bugs.python.org/issue41695
https://bugs.python.org/issue27674
The same problem occures in P3.7, P2.7, six.moves.http_cookies etc.
I know RFT says that cookie-name can't use brackets.
But you can set them to browser cookies.
RFC 6265:
xnovakj commentedon Nov 5, 2020
Possible patch, load parts one by one:
print c
Set-Cookie: id=12345
Set-Cookie: something=not_loaded
xnovakj commentedon Jan 4, 2022
New examples with the structured data.
Problems are with quotes and spaces inside { or [
cookie-script.com set those cookie data:
CookieScriptConsent={"action":"accept","categories":"[\\"performance\\"]"}
Python loads only cookies before that JSON structure
Conclusion:
Parsing JSON like cookie objects works, except quotes and without spaces.
Exist some new RFC with JSON data support?
How implementation/support/solution in diferent languages?
Exist another Python library which support cookie with JSON data?
[-]http.cookies.SimpleCookie.parse error after [keys][/-][+]http.cookies.SimpleCookie.parse error after [keys] or some JSON data values[/+][-]http.cookies.SimpleCookie.parse error after [keys][/-][+]http.cookies.SimpleCookie.parse error after [keys] or some JSON data values[/+]