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

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.");

[2222 byte] By [hauser@acm.orga] at [2007-11-27 8:49:28]
# 1
Based on offline discussion we're pretty sure this is not a JavaMail problem.
bshannona at 2007-7-12 20:58:50 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...