Java Mail fails to parse multipart Content-Type due to slash

Discussion in 'Java' started by Brian J. Sayatovic, Jun 25, 2004.

  1. I've narrowed down a problem I'm experiencing accepting an HTTP post
    to a failure of the Java Mail API 1.1 portion of J2EE 1.2.1 to parse
    the following Content-Type header:

    Content-Type: Multipart/Related;boundary=100fb0c59b90341754298fa8a1cb5fe4;type=text/xml;start="<4d06a28035510812f8c507ecbcad32__>"

    The flow is that a javax.mail.internet.ContentType is instantiated
    with the value of the header, the type and subtype ("Multipart" and
    "Related", respectively) are parsed, and then the paramemter list
    needs to be parsed.

    The parameter list is parsed by instantiating a
    javax.mail.internet.ParameterList with the parameter list value. That
    fails with a ParseException with no further information. Through
    trial and error, I was able to determine that the forward slash ("/")
    in the "type=text/xml" parameter of the parameter list is causing the
    problem. By eliminating that slash (or that parameter altogether),
    the parsing passes.

    The trouble is, as far as I have found, having a slash as part of the
    type parameter for a Multipart/Related Content-Type is perfectly legal
    and even necessary! Why is it, then, that the Java Mail API can't
    handle this?

    Regards,
    Brian.
     
    Brian J. Sayatovic, Jun 25, 2004
    #1
    1. Advertising

  2. Brian J. Sayatovic

    Chris Uppal Guest

    Brian J. Sayatovic wrote:

    > The trouble is, as far as I have found, having a slash as part of the
    > type parameter for a Multipart/Related Content-Type is perfectly legal
    > and even necessary! Why is it, then, that the Java Mail API can't
    > handle this?


    My reading of RFC 2045 (section 5.1) is that the

    type=text/xml

    bit is just a "parameter" according to the grammar. As such '/' is not a legal
    value in an unquoted value string.

    The '/' in Multipart/Related is legal without quotes (indeed quotes would not
    be legal there), but that is a different case in the grammar.

    In short, I think the content-type line should be (ignore the wrapping):

    Content-Type: Multipart/Related; boundary=100fb0c59b90341754298fa8a1cb5fe4;
    type="text/xml"; start="<4d06a28035510812f8c507ecbcad32__>"

    and that JavaMail is correct to refuse it.

    -- chris
     
    Chris Uppal, Jun 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pascal Steiss
    Replies:
    1
    Views:
    3,484
    Toby Inkster
    Mar 19, 2005
  2. Greg Collins [Microsoft MVP]

    Links to https fails 404 with preceding forward slash

    Greg Collins [Microsoft MVP], Jun 14, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    451
    Greg Collins [Microsoft MVP]
    Jun 15, 2006
  3. Fresh
    Replies:
    2
    Views:
    663
    Bo Persson
    Apr 22, 2008
  4. Patrick
    Replies:
    0
    Views:
    344
    Patrick
    Feb 17, 2004
  5. Replies:
    1
    Views:
    465
Loading...

Share This Page