patrick vrijlandt added the comment: 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-- ---------- Added file: http://bugs.python.org/file26764/cgibug.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15564> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com