multiple content-types break cgi.py

Janto Dreijer jantod at gmail.com
Sun Mar 4 05:03:23 EST 2007


Hi!

The Nokia Java SDK allows one to define multiple content-types in a
single HTTP header field. I'm not sure if it's standard, but it's
happening from some Java-enabled phones.

This breaks the FieldStorage class in cgi.py by not causing
self.read_urlencoded() to be called at object init. Specifically when
one gets a type value like 'text/plain, application/x-www-form-
urlencoded'.

Hacking one of the lines from:
        if ctype == 'application/x-www-form-urlencoded':
            self.read_urlencoded()
to
        if 'application/x-www-form-urlencoded' in [s.strip() for s in
ctype.split(",")]:
            self.read_urlencoded()
makes it work as expected.

The only reference to this "bug" I can find dates back to 1999:
http://tinyurl.com/3ahc3r

Regards
Janto




More information about the Python-list mailing list