Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ParseException Content-Disposition filename spaces

843830Mar 8 2007 — edited Aug 7 2008
Hello All,

I have an email generated from Thunderbird 1.5.0.9 (Windows/20061207) which contains an attachment whose filename has spaces.

JavaMail (1.4) throws a javax.mail.internet.ParseException on the MimeBodyPart.getDisposition() call:
javax.mail.internet.ParseException: Expected ';', got "-"
javax.mail.internet.ParameterList.<init>(ParameterList.java:179) 
javax.mail.internet.ContentDisposition.<init>(ContentDisposition.java:87) 
javax.mail.internet.MimeBodyPart.getDisposition(MimeBodyPart.java:1039) 
javax.mail.internet.MimeBodyPart.getDisposition(MimeBodyPart.java:299) 
The offending attachment part has a part header which looks like this:
Content-Disposition: inline;
	filename*0=Test - Test.pdf
Clearly the parser is failing due to the spaces in the filename. Bugzilla for Thunderbird (Bug 221028 - https://bugzilla.mozilla.org/show_bug.cgi?id=221028) discusses this issue, however the status of the bug is VERIFIED WONTFIX.

According to the Mozilla discussion, their implementation is conformant to the RFC:


...Just two days ago I was talking about this issue in #mozillazine with Christian
Biesinger and Boris Zbarsky, and they said that this is the proper behaviour
according to the RFC...


Whether it IS conformant to all relevant RFCs I don't know, but it seems it won't be changed any time soon.

This issue also exists for the Content-Type header in the same email which has the same format:
Content-Type: application/pdf;
	name*0=Test - Test.pdf
Anyone know if there is a way I can "safely" parse these headers? Is this a JavaMail bug?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 4 2008
Added on Mar 8 2007
18 comments
2,614 views