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.

classification
Title: cgi.py error on parsing/handling content-disposition
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: holtwick, jimjjewett, terry.reedy, zindel
Priority: normal Keywords:

Created on 2006-08-15 10:31 by holtwick, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cgtest.py holtwick, 2006-08-15 10:31 Patch with example for cpi.py:parse_header
cgtest.py zindel, 2008-07-28 15:05 patch for cgi.py with the test example
Messages (4)
msg29520 - (view) Author: Dirk Holtwick (holtwick) Date: 2006-08-15 10:31
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.
msg29521 - (view) Author: Jim Jewett (jimjjewett) Date: 2006-08-16 15:50
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.

msg70351 - (view) Author: Oleksiy Golovko (zindel) Date: 2008-07-28 15:05
Here is the another patch for this issue.
msg112647 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-03 18:26
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:19adminsetgithub: 43824
2010-08-03 18:26:23terry.reedysetstatus: open -> closed

nosy: + terry.reedy
messages: + msg112647

resolution: fixed
2008-07-28 15:05:51zindelsetfiles: + cgtest.py
nosy: + zindel
messages: + msg70351
title: cgi.py error on parsing/handling content-disposition -> cgi.py error on parsing/handling content-disposition
2006-08-15 10:31:58holtwickcreate