Commons Email
  1. Commons Email
  2. EMAIL-16

[email] Issue with cid URLs generated by .embed(...) in HtmlEmail.java

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: All

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

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Thorsten Vogel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development