Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3597

Attach a File with MailAttachment on Windows platform

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Neutral Neutral
    • None
    • 4.4.2
    • None
    • None
    • Windows + JDK 1.6 + Tomcat 5.5

      Using constructor info.magnolia.module.mail.templates.MailAttachment(File, String, String, String) results to an UnknownHostException while java mail is trying to get the file on Windows.
      The error comes from method MailAttachment.setPath(String) which constructs a URL with file:// + absolutePath. On *nix platforms it gives us a url like file:///tmp/myfile, but on Windows the url is file://C:/temp/myfile which is wrong (root slash is missing).
      I'd fix this issue by changing URL construction to :
      [143] this.url = new URL(FILE_URL_PREFIX + "/" + StringUtils.removeStart(aPath, "/"));
      I tested this fix on both Debian and Windows platforms.

        Acceptance criteria

              Unassigned Unassigned
              vgombert Vincent Gombert
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: