[
https://issues.apache.org/jira/browse/EMAIL-189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16903504#comment-16903504
]
Lee Jun Gyun edited comment on EMAIL-189 at 8/9/19 2:21 AM:
------------------------------------------------------------
when korean language is included in attachment file name, file name is broken.
If commons-email.jar not encode file name, file name is normal. I think that
because javax.mail-api.jar handles file name properly.
I guess without looking closely at javamail source. After commons-email.jar
handles file name included korean language, when javax.mail-api.jar handles
file name, I think there is a problem.
I posted a similar question on stackoverflow. It may be good to reference.
[https://stackoverflow.com/questions/57388873/why-attachment-file-name-broken-when-using-the-apache-email-library/57422337]
I think it would be nice to improve something like this:
{code:java}
public MultiPartEmail attach(
final DataSource ds,
String name,
final String description,
final String disposition,
boolean isEncode)
throws EmailException
{
if (EmailUtils.isEmpty(name))
{
name = ds.getName();
}
final BodyPart bodyPart = createBodyPart();
try
{
bodyPart.setDisposition(disposition);
if (isEncode)
{
bodyPart.setFileName(MimeUtility.encodeText(name));
}
else
{
bodyPart.setFileName(name);
}
bodyPart.setDescription(description);
bodyPart.setDataHandler(new DataHandler(ds));
getContainer().addBodyPart(bodyPart);
...
...
{code}
was (Author: simple):
when korean language is included in attachment file name, file name is broken.
If commons-email.jar not encode file name, file name is normal. I think that
because javax.mail-api.jar handles file name properly.
I guess without looking closely at javamail source. After commons-email.jar
handles file name included korean language, when javax.mail-api.jar handles
file name, I think there is a problem.
I posted a similar question on stackoverflow. It may be good to reference.
[https://stackoverflow.com/questions/57388873/why-attachment-file-name-broken-when-using-the-apache-email-library/57422337#57422337]
I think it would be nice to improve something like this:
{code:java}
public MultiPartEmail attach(
final DataSource ds,
String name,
final String description,
final String disposition,
boolean isEncode)
throws EmailException
{
if (EmailUtils.isEmpty(name))
{
name = ds.getName();
}
final BodyPart bodyPart = createBodyPart();
try
{
bodyPart.setDisposition(disposition);
if (isEncode)
{
bodyPart.setFileName(MimeUtility.encodeText(name));
}
else
{
bodyPart.setFileName(name);
}
bodyPart.setDescription(description);
bodyPart.setDataHandler(new DataHandler(ds));
getContainer().addBodyPart(bodyPart);
...
...
{code}
> if Korean language is included in attachment file name, attachment file name
> is broken.
> ---------------------------------------------------------------------------------------
>
> Key: EMAIL-189
> URL: https://issues.apache.org/jira/browse/EMAIL-189
> Project: Commons Email
> Issue Type: Bug
> Reporter: Lee Jun Gyun
> Priority: Major
> Fix For: 1.5
>
>
>
> if Korean language is included in attachment file name, attachment file name
> is broken.
> ex)
> [Attachment name]
> *attachment name :*
> 한글testfile한글한글한글한글testfile한글한글한글한글testfile한글한글한글한글testfile한글한글한글한글testfile한글한글한글한글testfile한글한글한글.txt
> *actual received attachment name in gmail :*
> =_UTF-8_Q_=ED=95=9C=EA=B8=80testfile=ED=95=9C=EA=B8=80_=
> =_UTF-8_Q_=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=80testfil_=
> =_UTF-8_Q_e=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=80=E___
> ___filename_3=__D=95=9.txt_=
> [Debug mode]
> Content-Type: text/plain; charset=UTF-8;
> name*0="=?UTF-8?Q?=ED=95=9C=EA=B8=80testfile=ED=95=9C=EA=B8=80?=
> =?U";
> name*1="TF-8?Q?=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=8";
> name*2="0testfil?=
> =?UTF-8?Q?e=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=80=E";
> name*3="D=95=9C?= =?UTF-8?Q?=EA=B8=80=ED=95=9C=EA=B8=80tes?=
> =?UTF-8";
> name*4="?Q?tfile=ED=95=9C?=
> =?UTF-8?Q?=EA=B8=80=ED=95=9C=EA=B8=80=ED";
> name*5="=95=9C=EA=B8=80=ED=95=9C=EA=B8=80?=
> =?UTF-8?Q?testfile=ED=95";
> name*6="=9C=EA=B8=80=ED=95=9C=EA=B8=80?=
> =?UTF-8?Q?=ED=95=9C=EA=B8=8";
> name*7="0=ED=95=9C=EA=B8=80testfile=ED=95=9C?=
> =?UTF-8?Q?=EA=B8=80=E";
> name*8="D=95=9C=EA=B8=80=ED=95=9C=EA=B8=80=ED=95=9C?=
> =?UTF-8?Q?=EA=";
> name*9="B8=80testf?=
> =?UTF-8?Q?ile=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=";
> name*10="80=ED=95=9C=EA=B8=80.txt?="
> Content-Transfer-Encoding: base64
> Content-Disposition: attachment;
> filename*0="=?UTF-8?Q?=ED=95=9C=EA=B8=80testfile=ED=95=9C=EA=B8=80?=
> =?U";
>
> filename*1="TF-8?Q?=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=8";
> filename*2="0testfil?=
> =?UTF-8?Q?e=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=80=E";
> filename*3="D=95=9C?= =?UTF-8?Q?=EA=B8=80=ED=95=9C=EA=B8=80tes?=
> =?UTF-8";
> filename*4="?Q?tfile=ED=95=9C?=
> =?UTF-8?Q?=EA=B8=80=ED=95=9C=EA=B8=80=ED";
> filename*5="=95=9C=EA=B8=80=ED=95=9C=EA=B8=80?=
> =?UTF-8?Q?testfile=ED=95";
> filename*6="=9C=EA=B8=80=ED=95=9C=EA=B8=80?=
> =?UTF-8?Q?=ED=95=9C=EA=B8=8";
> filename*7="0=ED=95=9C=EA=B8=80testfile=ED=95=9C?=
> =?UTF-8?Q?=EA=B8=80=E";
> filename*8="D=95=9C=EA=B8=80=ED=95=9C=EA=B8=80=ED=95=9C?=
> =?UTF-8?Q?=EA=";
> filename*9="B8=80testf?=
> =?UTF-8?Q?ile=ED=95=9C=EA=B8=80=ED=95=9C=EA=B8=";
> filename*10="80=ED=95=9C=EA=B8=80.txt?="
> When I analyzed the cause, it works normally if MimeUtility.encodeText is not
> called.
> ex)
> [not working]
> MultiPartEmail Line 467 bodyPart.setFileName(MimeUtility.encodeText(name));
> [normal working]
> MultiPartEmail Line 467 bodyPart.setFileName(name);
> Since I can not modify the MimeUtility source, I think that modifying
> MultiPartEmail.java is best.
> Can i provide PR on github?
> Thank you.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)