Re: Problem with parsing MimeMessage from InputStream

Chris Burdess <[email protected]>
Newsgroups gmane.comp.java.classpath.extensions.javamail
Message-ID <[email protected]>
Robert Mitchell wrote:
> I have some code where I want to parse a section of a message (read 
> from IMAP) as a MIME message using "new MimeMessage(session, 
> part.getInputStream())".  The input stream uses CRLF as line breaks, 
> but the code which parses the headers treats only the LF as the end of 
> line, leaving the CR on the end of each header line.  Worse, this 
> means that the blank line which separates the headers from the body 
> becomes a line containing a CR, meaning the end of the headers is 
> never detected.
>  
> I've traced it to code in InternetHeaders which uses a LineInputStream 
> to parse the headers.

Right: in all other paths we supply an input stream that is already 
wrapped by CRLFInputStream, but evidently not this one.

> It is possible that all that needs to be done is to use an instance of 
> CRLFInputStream as an intermediate wrapper.  Unfortunately, I do not 
> know the overall system well enough to be sure that would not have 
> unexpected consequences on other call paths into the InternetHeaders 
> constructor.

I believe that's the right thing to do, and I've updated 
InternetHeaders. Please let us know if this causes any other problems.
-- 
Chris Burdess
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.