Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Empty MIME parts are not parsed correctly #12

Open
glassfishrobot opened this issue May 27, 2014 · 3 comments
Open

Empty MIME parts are not parsed correctly #12

glassfishrobot opened this issue May 27, 2014 · 3 comments

Comments

@glassfishrobot
Copy link
Contributor

Raised from spray/spray#874

RFC 822 specifies the structure of a "message", which is a MIME part.

It says that the CRLF is optional if the body is empty:

message     =  fields *( CRLF *text )       ; Everything after
 ;  first null line
 ;  is message body

Also the current spec (rfc2046) for multipart messages has this in its grammar:

body-part := MIME-part-headers [CRLF *OCTET]

... so the following message is a valid MIME bundle with one empty part:

--UmzcCZZCSF5bhX4lRMbMNY8m
Content-Disposition: form-data; name=message
--UmzcCZZCSF5bhX4lRMbMNY8m--

.. but org.jvnet.mimepull parses this as a part with no headers and a content of "Content-Disposition: form-data; name=message"

This is demonstrated in the following failing Scala test:

import collection.JavaConversions._
import java.io._

class MimeParserSpec
  extends Specification {

    "org.jvnet.mimepull should understand empty BodyParts" in new Scope {
      val body = """mime preamble
mime preamble
--rNmigcMAf6HIo0Q2xJ9-vjkH
Content-Disposition: form-data; name=root-fields
--rNmigcMAf6HIo0Q2xJ9-vjkH--"""

      val mm = new org.jvnet.mimepull.MIMEMessage(
        new ByteArrayInputStream(body.getBytes), "rNmigcMAf6HIo0Q2xJ9-vjkH")

      mm.parseAll()
      mm.getAttachments.toList must beLike {
        case List(att) =>
          CharStreams.toString(new InputStreamReader(att.readOnce)) mustEqual ""
      }
    }
  }

.. this fails with 'Content-Disposition: form-data; name=root-fields' is not equal to ''

Affected Versions

[1.9.4]

@glassfishrobot
Copy link
Contributor Author

Reported by richard.bradley

@glassfishrobot
Copy link
Contributor Author

Was assigned to snajper

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA MIMEPULL-12

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant