Commons Email
  1. Commons Email
  2. EMAIL-138

Czech/Slovak diacritic marks in the file name of the attached file screw whole sent email

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.3.2
    • Fix Version/s: 1.3.3
    • Labels:
    • Environment:

      Windows 7, JDK 7 (6 compatible).

      Description

      Czech/Slovak diacritic marks in the file name of the attached file screw whole sent email. Email will arrive but it's content will be messy. An example of a filename which does this is "nazevřšččššě.txt". Optionally put some text in email and in file. I tried HtmlEmail.

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        5h 11m 1 Thomas Neidhart 06/May/14 21:32
        Resolved Resolved Closed Closed
        63d 23h 45m 1 Thomas Neidhart 09/Jul/14 21:17
        Closed Closed Reopened Reopened
        167d 12h 23m 1 Thomas Neidhart 24/Dec/14 08:41
        Hide
        Thomas Neidhart added a comment -

        I have tried to reproduce the problem now with different system charsets (property mail.mime.charset):

        for ISO-8859-15:

        Content-Disposition: attachment;
        filename="=?ISO-8859-15?Q?Test_Attachment_-_a>=E4,_o>=F6,_u>=FC,_au>=E4u?="
        

        for UTF-8:

        Content-Disposition: attachment;
        filename="=?utf-8?Q?Test_Attachment_-_a>=C3=A4,_o>=C3=B6,_u>=C3=BC,_au>=C3=A4u?="
        

        So you can see that the respective charset is used during the encoding of the filename and also part of the resulting mime message. When opening the resulting email with thunderbird, the correct filename is displayed.

        Can you more precisely specify the problem you are seeing?

        Show
        Thomas Neidhart added a comment - I have tried to reproduce the problem now with different system charsets (property mail.mime.charset): for ISO-8859-15: Content-Disposition: attachment; filename="=?ISO-8859-15?Q?Test_Attachment_-_a>=E4,_o>=F6,_u>=FC,_au>=E4u?=" for UTF-8: Content-Disposition: attachment; filename="=?utf-8?Q?Test_Attachment_-_a>=C3=A4,_o>=C3=B6,_u>=C3=BC,_au>=C3=A4u?=" So you can see that the respective charset is used during the encoding of the filename and also part of the resulting mime message. When opening the resulting email with thunderbird, the correct filename is displayed. Can you more precisely specify the problem you are seeing?
        Hide
        qed added a comment -

        @Nit: If it is as you say, then this issue shall be reopened. My tests were successful. I think my default codepage is Cp1250 for java. No problems reported so far. So if you have tested bugfix in 1.3.3 and it is as you say, please, report new issue.

        Show
        qed added a comment - @Nit: If it is as you say, then this issue shall be reopened. My tests were successful. I think my default codepage is Cp1250 for java. No problems reported so far. So if you have tested bugfix in 1.3.3 and it is as you say, please, report new issue.
        Thomas Neidhart made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Hide
        Nit added a comment -

        Hi Thomas Neidhart or qed , I found that the solution provided for this fix works only for systems which have default system encoding set to UTF-8.

        You should use MimeUtility.encodeText(fileToAttach.getName()), "UTF-8", null) to resolve this issue.
        Thanks

        Show
        Nit added a comment - Hi Thomas Neidhart or qed , I found that the solution provided for this fix works only for systems which have default system encoding set to UTF-8. You should use MimeUtility.encodeText(fileToAttach.getName()), "UTF-8", null) to resolve this issue. Thanks
        Thomas Neidhart made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Thomas Neidhart made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.3.3 [ 12326803 ]
        Resolution Fixed [ 1 ]
        Hide
        Thomas Neidhart added a comment -

        Fixed in r1592866.

        Thanks for the report!

        Show
        Thomas Neidhart added a comment - Fixed in r1592866. Thanks for the report!
        Hide
        Thomas Neidhart added a comment -

        The filename is not correctly encoded in case of non-ascii names.

        As a work-around you can do the following:

        HtmlEmail email = ...
        File fileToAttach = ...
        
        EmailAttachment attachment = new EmailAttachment();
        attachment.setName(MimeUtility.encodeText(fileToAttach.getName()));
        attachment.setDescription("blabla");
        attachment.setPath(fileToAttach.getAbsolutePath());
        email.attach(attachment);
        
        Show
        Thomas Neidhart added a comment - The filename is not correctly encoded in case of non-ascii names. As a work-around you can do the following: HtmlEmail email = ... File fileToAttach = ... EmailAttachment attachment = new EmailAttachment(); attachment.setName(MimeUtility.encodeText(fileToAttach.getName())); attachment.setDescription("blabla"); attachment.setPath(fileToAttach.getAbsolutePath()); email.attach(attachment);
        qed created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            qed
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development