Skip to content
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

Allow filename content disposition to have space in accordance with RFC6266 Appendix D #6826

Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGES/6826.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't encode ' ' as '%20' in a content-disposition's filename
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Artem Yushkovskiy
Arthur Darcet
Austin Scola
Ben Bader
Ben Cutler
Ben Greiner
Ben Timby
Benedikt Reinartz
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def content_disposition_header(
)
if quote_fields:
if key.lower() == "filename":
qval = quote(val, "", encoding=_charset)
qval = quote(val, " ", encoding=_charset)
lparams.append((key, '"%s"' % qval))
else:
try:
Expand Down
1 change: 1 addition & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ async def test_ceil_timeout_small_with_overriden_threshold(loop) -> None:
(dict(foo='bär "\\', quote_fields=False), 'attachment; foo="bär \\"\\\\"'),
(dict(foo="bär", _charset="latin-1"), "attachment; foo*=latin-1''b%E4r"),
(dict(filename="bär"), 'attachment; filename="b%C3%A4r"'),
(dict(filename="bar baz"), 'attachment; filename="bar baz"'),
(dict(filename="bär", _charset="latin-1"), 'attachment; filename="b%E4r"'),
(
dict(filename='bär "\\', quote_fields=False),
Expand Down