A header like this one containing a ";" and blanks in the content disposition fails: Content-Disposition: form-data; name="_media"; filename="Demo; 28.07.2006.jpg" The cause is, that the function parse_header() first splits the line by ";" and then begins to analize these parts. The part "filename" in our example is then split into two separate parts. I wrote a fix for the function parse_header(). It isn't still complete, because escaped '"' on the end of line are not respected, but in most cases it helps.
Logged In: YES user_id=764593 The test is good. The corner case is misses would also be a good test. I'm wondering whether a better fix might be to put parsing- around-quotes in a common library, and import it from there; these problems keep coming up, particularly in the web-related modules.
With 3.1.2, cgi.parse_header gives the same correct response as cgtest.parse_header, so I will assume that the same is true in 2.7 until demonstrated otherwise.
History
Date
User
Action
Args
2022-04-11 14:56:19
admin
set
github: 43824
2010-08-03 18:26:23
terry.reedy
set
status: open -> closednosy: + terry.reedymessages: + resolution: fixed
2008-07-28 15:05:51
zindel
set
files: + cgtest.pynosy: + zindelmessages: + title: cgi.py error on parsing/handling content-disposition -> cgi.py error on parsing/handling content-disposition