validate cookie Max-Age as -?digits before int()#12947
Draft
dxbjavid wants to merge 2 commits into
Draft
Conversation
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Merging this PR will not alter performance
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
CookieJar.update_cookiesreads aSet-CookieMax-Agewith a bareint(). Python'sint()is more permissive than :rfc:6265#section-5.2.2, which says aMax-Ageis"-"? DIGIT+and any other value must be ignored. SoMax-Age=+1000,Max-Age=1_000and whitespace-padded values are honoured and persist the cookie with the given lifetime, whereas a browser drops the attribute and keeps it as a session cookie. The jar already clears a clearly non-numeric value (Max-Age=string), so this just completes that existing intent by validating against-?[0-9]+before parsing.Are there changes in behavior for the user?
A
Set-CookiewhoseMax-Ageis not-?DIGIT+now leaves the cookie as a session cookie instead of giving it an expiry. Well-formed values, including negative ones, are unchanged.Is it a substantial burden for the maintainers to support this?
No, it is a small contained check next to the existing parse.
Related issue number
N/A
Checklist
CONTRIBUTORS.txtCHANGES/folder