From: Ben Darnell Date: Fri, 19 Nov 2010 22:04:53 +0000 (-0800) Subject: Don't assume 'boundary' is last field in Content-Type header. X-Git-Tag: v1.2.0~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e965556ff7a343864059c35bd8517f434d5c88e;p=thirdparty%2Ftornado.git Don't assume 'boundary' is last field in Content-Type header. http://groups.google.com/group/python-tornado/browse_thread/thread/d0531e331c189c56# Closes #172. --- diff --git a/tornado/httpserver.py b/tornado/httpserver.py index 42b5c866d..c9a424a36 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)