Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("*")),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Nonnumeric suffixes raise ValueError

When a Content-Disposition header contains a token-valid parameter such as filename*abc=foo, parse_content_disposition retains it and this sort key calls int("abc"), causing an uncaught ValueError when multipart filename or response content-disposition metadata is accessed.

Knowledge Base Used: Payloads, forms, and multipart bodies

Comment on lines 206 to +208

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Continuation sorting lacks coverage

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)
Expand Down
Loading