From 9e965556ff7a343864059c35bd8517f434d5c88e Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Fri, 19 Nov 2010 14:04:53 -0800 Subject: [PATCH] Don't assume 'boundary' is last field in Content-Type header. http://groups.google.com/group/python-tornado/browse_thread/thread/d0531e331c189c56# Closes #172. --- tornado/httpserver.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tornado/httpserver.py b/tornado/httpserver.py index 42b5c866..c9a424a3 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -357,9 +357,12 @@ class HTTPConnection(object): self._request.arguments.setdefault(name, []).extend( values) elif content_type.startswith("multipart/form-data"): - if 'boundary=' in content_type: - boundary = content_type.split('boundary=',1)[1] - if boundary: self._parse_mime_body(boundary, data) + fields = content_type.split(";") + for field in fields: + k, sep, v = field.partition("=") + if k == "boundary" and v: + self._parse_mime_body(v, data) + break else: logging.warning("Invalid multipart/form-data") self.request_callback(self._request)