This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author patrick.vrijlandt
Recipients orsenthil, patrick.vrijlandt, r.david.murray, v+python
Date 2012-08-11.13:03:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1344690228.12.0.243053985158.issue15564@psf.upfronthosting.co.za>
In-reply-to
Content
I would not know how to set the MIME-type of a file during upload. This is apparently set by the browser based on the filename (extension). Even (or: especially) if this is a bug in all the current browsers, python should provide the tools to adapt to this situation.

I could perhaps request the whole form to be "application/octet-stream", but the current "multipart/form-data" is appropriate for a form.

You are right about renaming. The innocent test file "test2.txt" can be uploaded, but the same file renamed to "test2.mht" causes an exception.

Below is a dump of the posted data (using Chrome in this case); attached a script (requiring bottle.py - www.bottlepy.org or PyPI) that demonstrates the problem.

There is no doubt that parsing fails; an exception cannot be the result of successful parsing. The input may be wrong, but python should offer the flexibility to handle wrong input.

Instead, are you sure it is appropriate to *automatically* dissect a file? It should be fairly easy to handle for the scripter if he really wants to dig deeper.

Headers

Origin: http://localhost:10080
Referer: http://localhost:10080/url-get
Content-Length: 349
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cache-Control: max-age=0
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.75 Safari/537.1
Host: localhost:10080
Accept-Encoding: gzip,deflate,sdch
Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4,en-GB;q=0.2
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBsBVBYDTxou89uBj

Body

------WebKitFormBoundaryBsBVBYDTxou89uBj
Content-Disposition: form-data; name="data"; filename="test2.mht"
Content-Type: multipart/related

# dit is een test
Dit is een regel
Dit is het einde.
#


------WebKitFormBoundaryBsBVBYDTxou89uBj
Content-Disposition: form-data; name="value"

abc123
------WebKitFormBoundaryBsBVBYDTxou89uBj--
History
Date User Action Args
2012-08-11 13:03:48patrick.vrijlandtsetrecipients: + patrick.vrijlandt, orsenthil, v+python, r.david.murray
2012-08-11 13:03:48patrick.vrijlandtsetmessageid: <1344690228.12.0.243053985158.issue15564@psf.upfronthosting.co.za>
2012-08-11 13:03:47patrick.vrijlandtlinkissue15564 messages
2012-08-11 13:03:46patrick.vrijlandtcreate