Crash with semicolon in filename

16 views
Skip to first unread message

Sylvain

unread,
Sep 30, 2009, 12:04:51 PM9/30/09
to Tornado Web Server
Hi,

If I upload a file with a semicolon (;) ["my;file.pdf"], Tornado
crashes

File "tornado\wsgi.py", line 172, in _parse_mime_body
name, name_value = name_part.strip().split("=", 1)
ValueError: need more than 1 value to unpack

Semicolon in filename is most of the time nerver well handled in
python (don't know why it is not fixed... or maybe I don't know how it
works) and we "often' get : "my" instead of "my;file.pdf".

But here, it crashes, so I think it needs to be fixed.

Best regards.

Sylvain

Bret Taylor

unread,
Sep 30, 2009, 3:33:04 PM9/30/09
to python-...@googlegroups.com
Thanks, we will investigate and fix.

Matt Goodall

unread,
Oct 1, 2009, 10:15:24 AM10/1/09
to Tornado Web Server
On Sep 30, 5:04 pm, Sylvain <sylvain.viv...@gmail.com> wrote:

> Semicolon in filename is most of the time nerver well handled in
> python (don't know why it is not fixed... or maybe I don't know how it
> works) and we "often' get : "my" instead of "my;file.pdf".

Use urlparse.urlsplit and your paths will be fine.

urlparse.urlparse tries to handle path args but gets it wrong. It's
best not to use it.

- Matt

Sylvain

unread,
Oct 1, 2009, 10:50:51 AM10/1/09
to Tornado Web Server
Here, the issue is when you upload a file (in a form with a file input
for example)
then the content-disposition is not well parsed.
Content-Disposition looks like that : attachment;
filename="myfile.pdf"

I think the "bug" in python is in cgi.parse_header (same kind of error
in Tornado I think)
http://pydoc.org/get.cgi/usr/local/lib/python2.5/cgi.py

There is a .split(";") --> error because, semi-colon can be used in
the filename too.

Regards.
Reply all
Reply to author
Forward
0 new messages