From 6c3f2ccd29d325842a5e90ac1441cfe3dc80b693 Mon Sep 17 00:00:00 2001 From: Benjamin Cutler Date: Thu, 14 Jul 2022 12:53:21 -0400 Subject: [PATCH 1/3] Allow filename content disposition to have space in accordance with RFC6266 Appendix D --- aiohttp/helpers.py | 2 +- tests/test_helpers.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py index 8e2502ac53b..9dd1a95ad04 100644 --- a/aiohttp/helpers.py +++ b/aiohttp/helpers.py @@ -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: diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 26afe82ef7e..8529294d4e2 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -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), From e72ed7b36d309dcbfcd7e0042aaaf4145eafc815 Mon Sep 17 00:00:00 2001 From: Benjamin Cutler Date: Thu, 14 Jul 2022 12:58:45 -0400 Subject: [PATCH 2/3] Add release notes to CHANGES --- CHANGES/6826.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/6826.bugfix diff --git a/CHANGES/6826.bugfix b/CHANGES/6826.bugfix new file mode 100644 index 00000000000..22268f78195 --- /dev/null +++ b/CHANGES/6826.bugfix @@ -0,0 +1 @@ +Don't encode ' ' as '%20' in a content-disposition's filename From 9465e56007a198e1b20dc97ff7a433dddcd04cec Mon Sep 17 00:00:00 2001 From: Benjamin Cutler Date: Thu, 14 Jul 2022 13:00:26 -0400 Subject: [PATCH 3/3] add me as contributor : ) --- CONTRIBUTORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index bd7677f5f29..210bc80e37b 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -52,6 +52,7 @@ Artem Yushkovskiy Arthur Darcet Austin Scola Ben Bader +Ben Cutler Ben Greiner Ben Timby Benedikt Reinartz