-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: sort RFC 2231 parameter continuations numerically #13563
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,7 +204,8 @@ def content_disposition_filename( | |
| else: | ||
| parts = [] | ||
| fnparams = sorted( | ||
| (key, value) for key, value in params.items() if key.startswith(name_suf) | ||
| ((key, value) for key, value in params.items() if key.startswith(name_suf)), | ||
| key=lambda kv: int(kv[0].split("*", 1)[1].rstrip("*")), | ||
|
Comment on lines
206
to
+208
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This changes RFC 2231 continuation ordering without adding focused tests for indices of 10 or greater and nonnumeric continuation-like names, leaving both the intended fix and malformed-input compatibility unprotected against regression. Context Used: AGENTS.md (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| ) | ||
| for num, (key, value) in enumerate(fnparams): | ||
| _, tail = key.split("*", 1) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a Content-Disposition header contains a token-valid parameter such as
filename*abc=foo,parse_content_dispositionretains it and this sort key callsint("abc"), causing an uncaughtValueErrorwhen multipart filename or response content-disposition metadata is accessed.Knowledge Base Used: Payloads, forms, and multipart bodies