bug in MIME header parsing

Cedric Hyppolite <[email protected]> Mon, 24 Apr 2006 23:37:37 +0200
Newsgroups gmane.comp.java.classpath.extensions.discuss
Message-ID <[email protected]>
Hi,

I think I have found a bug in the handling of the MIME headers.

When sending a mail with an image attached the header is the  
following, when passing in function MimeBodyPart.getHeader(name,  
delimiter)

Sent mail:

getHeader Content-Type on
Header : Name 'Content-Type' Value 'image/png'
Header : Name 'Content-Transfer-Encoding' Value 'base64'
Header : Name 'Content-Disposition' Value 'attachment; filename=jsf- 
banner.png'
Header : Name 'Content-ID' Value '<e944d2ce-d3d4-11da-a54c- 
e9bd449d3aa2>'returns 1 elements

Received mail:

getHeader Content-Type on
Header : Name 'Content-Type' Value 'image/png'
Header : Name 'Content-Id' Value 'BASE64'
Header : Name 'Content-Description' Value '7798'
Header : Name 'Content-Disposition' Value '<e944d2ce-d3d4-11da-a54c- 
e9bd449d3aa2>'returns image/png


The mail header as seen in my client is:
------=_Part_0_3353614.1145912236129
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=jsf-banner.png
Content-ID: <e944d2ce-d3d4-11da-a54c-e9bd449d3aa2>

I see an issue when using the IMAP provider, whereas the same mail  
can be sent and received without problems using POP.

I found this message highlighing a problem in the  
InternetHeaders.load function. In the code that I got (CVS as of  
Feb12) and in the latest, the fix proposed in the mail is not applied  
(use of CRLFInputStream)
  http://lists.gnu.org/archive/html/classpathx-javamail/2005-03/ 
msg00003.html

I would guess that the problem comes from MimeMultipart.parse around  
line 400.

So my question is: How can this parsing problem be fixed ? And is  
there any code/test for MIME support that I could use as example of  
how I should use the API
to be able to send/receive MIME mail in POP/IMAP ?

Thanks in advance,
Cedric