Visitar URL original
bpo-45358 Add new cookie attributes by glubsy · Pull Request #28726 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20250528111703/https://github.com/python/cpython/pull/28726
Skip to content

bpo-45358 Add new cookie attributes #28726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

glubsy
Copy link

@glubsy glubsy commented Oct 4, 2021 •

https://bugs.python.org/issue45358

Google (more specifically Youtube) sometimes generates cookie headers with Priority=Level and SameParty attributes which are non-standard.

  • Discarding cookies after encountering an unknown attribute altogether might become problematic for some use cases (web browsers do not drop the cookie but simply ignore the unexpected attribute).

  • After parsing Priority=High attribute (for example), a bogus cookie (morsel) is generated with its key/value set to Priority=High, which is an unexpected behaviour.
    Adding these two keys to the list of reserved attributes seems to be the only way to avoid generating such incorrect morsel whenever we encounter a key=value pair that is actually meant to be an attribute.

https://bugs.python.org/issue45358

glubsy added 3 commits October 3, 2021 18:58
If adding more than one key/value pair to the list, the subsequent keys would
generate a new Morsel. There should be only one TYPE_KEYVALUE per Cookie.
We avoid adding anymore key/value as TYPE_KEYVALUE to the list (only attributes
should be added after the first one). We could add these subsequent pairs as
TYPE_ATTRIBUTE, but at this point in the function these would be invalid keys
(ie. not present in a Morsel's reserved keys or flags).
We keep the cookie valid despite the invalid attribute: we simply ignore it.
Sometimes an attribute is not part of a Morsel's definition.
Instead of discarding the cookie altogether, keep the cookie but
ignore the invalid attributes.
Google has decided to add a Priority key/value and a SameParty
flag as part of valid cookie attributes.
Adding these to reserved attributes avoids erroneously generating
orphan morsels: the Priority key/value would otherwise be
interpreted as a new cookie instead of an attribute.
@github-actions
Copy link

github-actions bot commented Nov 9, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Nov 9, 2021
@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants