Skip to content

gh-154546: Validate cookie key before applying in BaseCookie.load()#154547

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-cookies-partial-state
Open

gh-154546: Validate cookie key before applying in BaseCookie.load()#154547
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-cookies-partial-state

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Move the `_is_legal_key()` check from the apply phase (`Morsel.set()`) into the parse phase of `__parse_string`, so an illegal key raises `CookieError` before any cookies are written to the jar.

Related to gh-84183 (raise-vs-silent inconsistency) but orthogonal: this fixes partial state when an error IS raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant