diff --git a/CHANGES/10270.bugfix.rst b/CHANGES/10270.bugfix.rst new file mode 100644 index 00000000000..e3252464dc8 --- /dev/null +++ b/CHANGES/10270.bugfix.rst @@ -0,0 +1,2 @@ +``MultipartForm.decode()`` must follow RFC1341 7.2.1 with a ``CRLF`` after the boundary +-- by :user:`imnotjames`. diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 591142d469e..03e35ce789f 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -175,6 +175,7 @@ Jaesung Lee Jake Davis Jakob Ackermann Jakub Wilk +James Ward Jan Buchar Jan Gosmann Jarno Elonen diff --git a/aiohttp/multipart.py b/aiohttp/multipart.py index dc25a83b17a..052e420a302 100644 --- a/aiohttp/multipart.py +++ b/aiohttp/multipart.py @@ -983,7 +983,7 @@ def decode(self, encoding: str = "utf-8", errors: str = "strict") -> str: return "".join( "--" + self.boundary - + "\n" + + "\r\n" + part._binary_headers.decode(encoding, errors) + part.decode() for part, _e, _te in self._parts diff --git a/tests/test_web_response.py b/tests/test_web_response.py index f8cf233e148..493e5e66f27 100644 --- a/tests/test_web_response.py +++ b/tests/test_web_response.py @@ -1063,7 +1063,7 @@ def read(self, size: int = -1) -> bytes: (BodyPartReader(b"x", CIMultiDictProxy(CIMultiDict()), mock.Mock()), None), ( mpwriter, - "--x\nContent-Type: text/plain; charset=utf-8\r\nContent-Length: 4\r\n\r\ntest", + "--x\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Length: 4\r\n\r\ntest", ), ), )