cgi.py?

david.tolpin at gmail.com david.tolpin at gmail.com
Sun May 29 17:03:33 EDT 2005


Hi,

I've looked into cgi.py from 2.4's distribution, and its contents
puzzle me. In parse_header, the first line splits on ';':

    plist = map(lambda x: x.strip(), line.split(';'))

but header parameters may contain semicolon in quoted strings:

   Content-Type: image/jpeg; filename="home:lib;images;face.jpg"

and headers like this one will be parsed incorrectly. A few subsequent
lines unquote a quoted value, but the only place where quoted-string
production is defined is RFC 3875, and there is no quote escaping in
the production (nor in any other draft or related RFC). So, even if the
former is fixed, the latter will still prevent headers like

  Content-Type: text/plain; filename="c:\files\"; title="My Files"

from being parsed correctly. What am I missing?

David




More information about the Python-list mailing list