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!

quoted-printable transfer encoding producing a single dot on a line

843830Jun 26 2007 — edited Jun 28 2007
Subject: javamail breaking signatures - "mail.mime.cachemultipart" not
always working?

Attachments: result.eml.zip; jottMini.eml.zip

Hi Bill,

The below example reads a mime message from a file and constructs a new one from the bodyparts.
Unfortunately, when writing the newly created mail to an output-stream, a line only containing a single dot "." is created by javamail.

Also, a line starting with a "." is created:
"..shape {behavior:url(#default#VML);}"

I subsequently sign this message mail it off. Apparently, this is not reliably transmitted over the internet and when I receive it again, one or two dots are missing and thus the signature is broken.

I see a very old reference to a similar problem -
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4305687 , but I am not clear whether "quoted-printable" encoding is broken or what is the situation here? Setting a Content-Transfer-Encoding header to base64 appears to be a work-around, but I'd rather understand whether you think that the default content-transfer-encoding should be able to handle this without further measures taken?

Regards

Ralf

P.S.: For your reference, I am happy to send you the input and result emls both zipped to avoid alteration ins transit. I also put them on http://www.bluseal.com/openssl/result.eml.zip and http://www.bluseal.com/openssl/jottMini.eml.zip

System.setProperty("mail.mime.cachemultipart", "false");
FileInputStream fin = new FileInputStream("jottMini.eml");
MimeMessage msg = new MimeMessage(Session.getDefaultInstance(
System.getProperties()), fin);
MimeMessage msgOut = new MimeMessage(Session
.getDefaultInstance(System.getProperties()));
MimeMultipart mp = new MimeMultipart();
mp.setSubType("alternative");
MimeMultipart mpIn = (MimeMultipart) msg.getContent();
mp.addBodyPart(mpIn.getBodyPart(0));
mp.addBodyPart(mpIn.getBodyPart(1));
msgOut.setContent(mp);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
msgOut.writeTo(baos);
String outMsgString = new String(baos.toByteArray());
int i = outMsgString.indexOf("\n.");
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 26 2007
Added on Jun 26 2007
1 comment
247 views