multiple content-types break cgi.py

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Janto Dreijer

    multiple content-types break cgi.py

    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_urlen coded() 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_urlen coded()
    to
    if 'application/x-www-form-urlencoded' in [s.strip() for s in
    ctype.split("," )]:
    self.read_urlen coded()
    makes it work as expected.

    The only reference to this "bug" I can find dates back to 1999:


    Regards
    Janto

  • Jon Ribbens

    #2
    Re: multiple content-types break cgi.py

    In article <1173002603.690 853.250090@p10g 2000cwp.googleg roups.com>, Janto Dreijer wrote:
    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.
    >
    The only reference to this "bug" I can find dates back to 1999:
    http://tinyurl.com/3ahc3r
    It's not a bug - sending multiple content-types is just totally broken.
    What would such a header even be supposed to mean? It's like saying
    "this is an apple orange".

    Comment

    • Marc 'BlackJack' Rintsch

      #3
      Re: multiple content-types break cgi.py

      In <slrneul7rs.t3l .jon+usenet@sno wy.squish.net>, Jon Ribbens wrote:
      It's not a bug - sending multiple content-types is just totally broken.
      What would such a header even be supposed to mean? It's like saying
      "this is an apple orange".
      And the correct header for such a beast would be "this is an iOrange" of
      course. ;-)

      SCNR,
      Marc 'BlackJack' Rintsch

      Comment

      • Janto Dreijer

        #4
        Re: multiple content-types break cgi.py

        On Mar 4, 12:29 pm, Jon Ribbens <jon+use...@une quivocal.co.ukw rote:
        In article <1173002603.690 853.250...@p10g 2000cwp.googleg roups.com>, Janto Dreijer wrote:
        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.
        >
        The only reference to this "bug" I can find dates back to 1999:
        http://tinyurl.com/3ahc3r
        >
        It's not a bug - sending multiple content-types is just totally broken.
        What would such a header even be supposed to mean? It's like saying
        "this is an apple orange".
        Hmmm. Thanks! I suspected as much.

        Rough inspection suggests that calling
        connection.setR equestProperty( "Content-Type", "applicatio n/x-www-
        form-urlencoded");
        on the Nokia 6230 would actually cause the value to be *appended* and
        not set.

        Yuck! It looks like I'm going to have to keep a modified copy of
        cgi.py if I want to support the phone. Or hack something on the Java
        side.

        Janto

        Comment

        • Jon Ribbens

          #5
          Re: multiple content-types break cgi.py

          In article <1173040160.844 329.48050@s48g2 000cws.googlegr oups.com>, Janto Dreijer wrote:
          >It's not a bug - sending multiple content-types is just totally broken.
          >What would such a header even be supposed to mean? It's like saying
          >"this is an apple orange".
          >
          Hmmm. Thanks! I suspected as much.
          >
          Rough inspection suggests that calling
          connection.setR equestProperty( "Content-Type", "applicatio n/x-www-
          form-urlencoded");
          on the Nokia 6230 would actually cause the value to be *appended* and
          not set.
          If that method is inherited from java.net.URLCon nection, then if the
          phone is behaving as you suggest, its Java library is bugged and
          behaving contrary to Sun's Java documentation.

          Comment

          Working...