René's URL Explorer Experiment


Title: SimpleCookie() fails for json-like values with embedded double-quotes · Issue #92936 · python/cpython · GitHub

Open Graph Title: SimpleCookie() fails for json-like values with embedded double-quotes · Issue #92936 · python/cpython

X Title: SimpleCookie() fails for json-like values with embedded double-quotes · Issue #92936 · python/cpython

Description: Bug report http.cookies.SimpleCookie() takes a string and should return a dict-like parse of the result. On some parse errors, it returns an empty dict, or one sparsely populated with values, for example on success on a cookie with two n...

Open Graph Description: Bug report http.cookies.SimpleCookie() takes a string and should return a dict-like parse of the result. On some parse errors, it returns an empty dict, or one sparsely populated with values, for e...

X Description: Bug report http.cookies.SimpleCookie() takes a string and should return a dict-like parse of the result. On some parse errors, it returns an empty dict, or one sparsely populated with values, for e...

Opengraph URL: https://github.com/python/cpython/issues/92936

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SimpleCookie() fails for json-like values with embedded double-quotes","articleBody":"\r\n**Bug report**\r\n`http.cookies.SimpleCookie()` takes a string and should return a dict-like parse of the result. On some parse errors, it returns an empty dict, or one sparsely populated with values, for example on success on a cookie with two name-value pairs:\r\n```\r\n>>> import http.cookies.SimpleCookie('a1=b;a2=\"c d\";')\r\n\u003cSimpleCookie: a1='b' a2='c d'>\r\n```\r\n\r\nCookies consist of name-value pairs, both of which have legal character subsets as defined in RFC2068 and RFC2109. Actual browser / server implementations are more lenient and `cookies.py` source includes such acknowledgement.\r\n```\r\n# Pattern for finding cookie\r\n#\r\n# This used to be strict parsing based on the RFC2109 and RFC2068\r\n# specifications.  I have since discovered that MSIE 3.0x doesn't\r\n# follow the character rules outlined in those specs.  As a\r\n# result, the parsing rules here are less strict.\r\n```\r\nCool. Modern times bring more exceptions. Specifically, Google's OAUTH implementation now includes a cookie (`g_state`) whose value appears to be JSON, and embedded double quotes cause SimpleCookie() to fail (or actually \"succeed\" in a useless way):\r\n\r\n```\r\n>>> import http.cookies.SimpleCookie('a1={\"b\":c};')\r\n\u003cSimpleCookie: >\r\n```\r\n\r\n**Bug Fix/Modest Proposal**\r\nRather than trying to get Google to change their cookie format (which is happily supported by common browsers), or requiring users of `http.cookie` module write their own parsers, I suggest simple augmentation of the regular expression used to \"find cookies\".\r\n\r\nThe change would simply allow any number of embedded double quotes. The following snippet adds two lines to the existing `_CookiePattern` as found in `cpython/Lib/http/cookies.py`:\r\n```\r\n_CookiePattern = re.compile(r\"\"\"\r\n    \\s*                            # Optional whitespace at start of cookie\r\n    (?P\u003ckey>                       # Start of group 'key'\r\n    [\"\"\" + _LegalKeyChars + r\"\"\"]+?   # Any word of at least one letter\r\n    )                              # End of group 'key'\r\n    (                              # Optional group: there may not be a value.\r\n    \\s*=\\s*                          # Equal Sign\r\n    (?P\u003cval>                         # Start of group 'val'\r\n    \"(?:[^\\\\\"]|\\\\.)*\"                  # Any doublequoted string\r\n    |                                  # or\r\n    \\w{3},\\s[\\w\\d\\s-]{9,11}\\s[\\d:]{8}\\sGMT  # Special case for \"expires\" attr\r\n    |                                  # or\r\n    [\"\"\" + _LegalValueChars + r\"\"\"]*      # Any word or empty string\r\n# additional clause vvvvv\r\n    |                                                                                                                                               \r\n    [\"\"\" + _LegalValueChars + r\"\"\"]+[\"\"\" + _LegalValueChars + r'\"]*[' + _LegalValueChars + r\"\"\"]+      # Any word with internal quotes              \r\n# end ^^^^\r\n    )                                # End of group 'val'\r\n    )?                             # End of optional value group\r\n    \\s*                            # Any number of spaces.\r\n    (\\s+|;|$)                      # Ending either at space, semicolon, or EOS.\r\n    \"\"\", re.ASCII | re.VERBOSE)    # re.ASCII may be removed if safe.\r\n```\r\nThe two added lines merely permit cookie _values_ to contain any number of double quotes, as long as the first and last character of the value _is not_ a double quote. No further interpretation of cookie value (such as json validation) is attempted or warranted.\r\n\r\n**Your environment**\r\nObserved initially in 3.8.10 (linux), confirmed 3.10.1 (Mac) and observed the code in `cpython/Lib/http/cookies.py:437`.\r\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-113663\n* gh-137566\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/pbuckner","@type":"Person","name":"pbuckner"},"datePublished":"2022-05-18T23:26:12Z","url":"https://github.com/python/cpython/issues/92936"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e6994914-320f-839f-60f0-909948cbbda9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id89EA:97D39:1049352:1576EAC:6B020F38
html-safe-noncea3c50bbe8ce85ccedc92e8eba6723949202c13a59777668369ac979c359a1c2e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUVBOjk3RDM5OjEwNDkzNTI6MTU3NkVBQzo2QjAyMEYzOCIsInZpc2l0b3JfaWQiOiIyMTc1NDEzMjkzODQwMjA3NjcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac4774e7da7068311c5bb5ffb6e61b9407d807f91a0be2af3b49e09bfb2cafe770
hovercard-subject-tagissue:1240710790
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/92936/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ba2349d095f898c3b417c7261dd84c50107780c003687d8e1b3cfe6c7ac8a8a5/python/cpython/issues/92936
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ba2349d095f898c3b417c7261dd84c50107780c003687d8e1b3cfe6c7ac8a8a5/python/cpython/issues/92936
og:image:altBug report http.cookies.SimpleCookie() takes a string and should return a dict-like parse of the result. On some parse errors, it returns an empty dict, or one sparsely populated with values, for e...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepbuckner
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/92936#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F92936
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F92936
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/92936
Reloadhttps://github.com/python/cpython/issues/92936
Reloadhttps://github.com/python/cpython/issues/92936
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/92936
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/92936
SimpleCookie() fails for json-like values with embedded double-quoteshttps://github.com/python/cpython/issues/92936#top
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/pbuckner
pbucknerhttps://github.com/pbuckner
on May 18, 2022https://github.com/python/cpython/issues/92936#issue-1240710790
gh-92936: allow double quote in cookie values #113663https://github.com/python/cpython/pull/113663
gh-92936: update http.cookies docs post GH-113663 #137566https://github.com/python/cpython/pull/137566
Nexthttps://github.com/python/cpython/issues/92936?timeline_page=1
pbucknerhttps://github.com/pbuckner
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on May 18, 2022https://github.com/python/cpython/issues/92936#event-6636686186
serhiy-storchakahttps://github.com/serhiy-storchaka
Cookies issues 🍪https://github.com/orgs/python/projects/13
on May 20, 2022https://github.com/python/cpython/issues/92936#event-15227868431
https://github.com/NewUserHa
NewUserHahttps://github.com/NewUserHa
on May 27, 2022https://github.com/python/cpython/issues/92936#issuecomment-1139499652
https://github.com/pbuckner
pbucknerhttps://github.com/pbuckner
on May 27, 2022https://github.com/python/cpython/issues/92936#issuecomment-1139760268
https://github.com/NewUserHa
NewUserHahttps://github.com/NewUserHa
on May 27, 2022https://github.com/python/cpython/issues/92936#issuecomment-1139778465
https://github.com/pbuckner
pbucknerhttps://github.com/pbuckner
on May 27, 2022https://github.com/python/cpython/issues/92936#issuecomment-1139785598
https://github.com/NewUserHa
NewUserHahttps://github.com/NewUserHa
on May 27, 2022https://github.com/python/cpython/issues/92936#issuecomment-1139803682
https://github.com/pbuckner
pbucknerhttps://github.com/pbuckner
on May 27, 2022https://github.com/python/cpython/issues/92936#issuecomment-1139918867
https://github.com/NewUserHa
NewUserHahttps://github.com/NewUserHa
on May 27, 2022https://github.com/python/cpython/issues/92936#issuecomment-1140074116
https://github.com/kbower
kbowerhttps://github.com/kbower
on Aug 30, 2023https://github.com/python/cpython/issues/92936#issuecomment-1698646010
@pbucknerhttps://github.com/pbuckner
https://github.com/pbuckner
pbucknerhttps://github.com/pbuckner
on Aug 31, 2023https://github.com/python/cpython/issues/92936#issuecomment-1701796113
https://github.com/kbower
kbowerhttps://github.com/kbower
on Aug 31, 2023https://github.com/python/cpython/issues/92936#issuecomment-1701901576
@pbucknerhttps://github.com/pbuckner
iritkatrielhttps://github.com/iritkatriel
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Nov 23, 2023https://github.com/python/cpython/issues/92936#event-11050517064
https://github.com/nburns
nburnshttps://github.com/nburns
on Jan 3, 2024https://github.com/python/cpython/issues/92936#issuecomment-1875756068
#113663https://github.com/python/cpython/pull/113663
https://github.com/Dreamsorcerer
Dreamsorcererhttps://github.com/Dreamsorcerer
on Sep 4, 2024https://github.com/python/cpython/issues/92936#issuecomment-2329144208
This discussionhttps://stackoverflow.com/questions/1969232/what-are-allowed-characters-in-cookies#1969339
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Aug 8, 2025https://github.com/python/cpython/issues/92936#issuecomment-3169085639
https://docs.python.org/3/library/http.cookies.htmlhttps://docs.python.org/3/library/http.cookies.html
picnixzhttps://github.com/picnixz
on Aug 8, 2025https://github.com/python/cpython/issues/92936#event-19060983481
picnixzhttps://github.com/picnixz
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
on Aug 8, 2025https://github.com/python/cpython/issues/92936#event-19060991499
https://github.com/nburns
nburnshttps://github.com/nburns
on Aug 8, 2025https://github.com/python/cpython/issues/92936#issuecomment-3169190592
@picnixzhttps://github.com/picnixz
https://github.com/nburns
nburnshttps://github.com/nburns
on Aug 8, 2025https://github.com/python/cpython/issues/92936#issuecomment-3169390847
#71861https://github.com/python/cpython/issues/71861
#86111https://github.com/python/cpython/issues/86111
orsenthilhttps://github.com/orsenthil
on Aug 15, 2025https://github.com/python/cpython/issues/92936#event-19181847306
gh-92936: update `http.cookies` docs post GH-113663 (#137566)https://github.com/python/cpython/commit/d86c2257a69a8d6c650c0db470499463131a569f
gh-92936https://github.com/python/cpython/issues/92936
GH-113663https://github.com/python/cpython/pull/113663
#137566https://github.com/python/cpython/pull/137566
d86c225https://github.com/python/cpython/commit/d86c2257a69a8d6c650c0db470499463131a569f
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Aug 18, 2025https://github.com/python/cpython/issues/92936#issuecomment-3197658987
picnixzhttps://github.com/picnixz
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 18, 2025https://github.com/python/cpython/issues/92936#event-19207803621
Agent-Hellboyhttps://github.com/Agent-Hellboy
on Aug 19, 2025https://github.com/python/cpython/issues/92936#event-19221824236
pythongh-92936: allow double quote in cookie values (python#113663)https://github.com/Agent-Hellboy/cpython/commit/ceccec0ee3462d05519b959500688371ec150fae
pythongh-92936https://github.com/python/cpython/issues/92936
python#113663https://github.com/python/cpython/pull/113663
ceccec0https://github.com/Agent-Hellboy/cpython/commit/ceccec0ee3462d05519b959500688371ec150fae
pythongh-92936: update `http.cookies` docs post pythonGH-113663 (pyth…https://github.com/Agent-Hellboy/cpython/commit/a93c7c12ccae6916bb128bc87dd01d43108479df
pythongh-92936https://github.com/python/cpython/issues/92936
pythonGH-113663https://github.com/python/cpython/pull/113663
pyth…https://github.com/python/cpython/pull/137566
a93c7c1https://github.com/Agent-Hellboy/cpython/commit/a93c7c12ccae6916bb128bc87dd01d43108479df
https://github.com/collinanderson
collinandersonhttps://github.com/collinanderson
on Jan 30, 2026https://github.com/python/cpython/issues/92936#issuecomment-3825455694
https://github.com/django/django/blob/main/django/http/cookie.pyhttps://github.com/django/django/blob/main/django/http/cookie.py
https://code.djangoproject.com/ticket/33212https://code.djangoproject.com/ticket/33212
https://github.com/Dreamsorcerer
Dreamsorcererhttps://github.com/Dreamsorcerer
on Jan 31, 2026https://github.com/python/cpython/issues/92936#issuecomment-3828490765
serhiy-storchakahttps://github.com/serhiy-storchaka
on Apr 30, 2026https://github.com/python/cpython/issues/92936#event-25049182436
gh-149028: Revert gh-92936 changes (GH-149182)https://github.com/python/cpython/commit/c80e446e6b91fb64e1cbfed8986869accd1fafb6
gh-149028https://github.com/python/cpython/issues/149028
gh-92936https://github.com/python/cpython/issues/92936
GH-149182https://github.com/python/cpython/pull/149182
c80e446https://github.com/python/cpython/commit/c80e446e6b91fb64e1cbfed8986869accd1fafb6
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/92936
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/92936
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
Cookies issues 🍪https://github.com/orgs/python/projects/13
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.