Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Nightly Builds
-
None
-
None
-
Operating System: other
Platform: All
-
30634
Description
There seems to be an issue with the content-id (cid) returned by the
.embed(...) member in HtmlEmail.java. The function sometimes returns cids
with may also contain single quotes ' or double quotes " (all within ascii
range 32-126). These random strings break the HTML code when a cid is
referenced in an img-tag, e.g. <img src="cid:hju4"4u23">. Since this is a
random function, it only happens from time to time. Tests with Outlook,
Lotus Notes and Apple Mail clients show that they cannot render those
images, because their html parser only returns a portion of the actual cid.
I have tried to encode the cid (with commons URLCodec), but that doesn't work
either.
Fixed it by using RandomStringUtils.randomAlphabetic(...) in the .embed()
function in HtmlEmail.java, instead of .randomAscii(...). Could also be
fixed by using a combination of .randomNumeric(...) +
.randomAlphabetic(...), but the result should not contain url-offending
characters Also consider to use the commons-id package as soon as it is
stable.
This patch works for me so far:
% cvs diff HtmlEmail.java
Index: HtmlEmail.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons-sandbox/email/src/java/org/apache/commons/mail/HtmlEmail.java,v
retrieving revision 1.8
diff -r1.8 HtmlEmail.java
145c145
< String cid = RandomStringUtils.randomAscii(10);
—
> String cid = RandomStringUtils.randomAlphabetic(10);