play1 icon indicating copy to clipboard operation
play1 copied to clipboard

fix cc mailaddress display name Garbled on multibyte character

Open ken-takagi opened this issue 5 years ago • 9 comments

Purpose

fix cc mailaddress display name Garbled on multibyte character

Background Context

same bcc list approach?

References

ken-takagi avatar Feb 05 '20 06:02 ken-takagi

Hello. We use this play1 for our production, and want this PR to be merged.

https://lighthouseapp.com/dashboard seems to be unavailable, so we can't figure out how to contact the reviewer of this project ...

We really appreciate if you notice and make any response. Thank you.

to-lz1 avatar Jul 07 '21 02:07 to-lz1

Hi @to-lz1

Play developers definitely still see what's happening here, and this is the right place to discuss about it ! I do not see anything preventing from this PR to be merged, but releases are indeed not frequent. Maybe @xael-fry or @asolntsev could plan a next release soon ?

Meanwhile, you could also use a custom build of Play which would include this PR and use it. Tell us if you need some tips to do so.

tomparle avatar Jul 07 '21 09:07 tomparle

That's right, we do see pull requests and comments.

In this pull request, I would like to see a unit-test showing that the change does work. I expect to see the email sample that did need such a change.

Then @xael-fry could make a release.

asolntsev avatar Jul 07 '21 11:07 asolntsev

@tomparle @asolntsev

Thank you very much for your quick response!

I was relieved to hear that Play developers still check here, and I agree with @asolntsev. I think it would be better to add some unit-test and email samples to this PR. I'll talk to @ken-takagi about that (in fact, he is my colleague).

to-lz1 avatar Jul 07 '21 13:07 to-lz1

@asolntsev Hi, I took a look at this issue.

Without this change, mail address handling will be slightly different from what we expect.

jshell> import org.apache.commons.mail.SimpleEmail;
jshell> import javax.mail.internet.InternetAddress;

jshell> Email sampleMail = new SimpleEmail();
jshell> String multibyteCharAddress = "Eva Nováková <[email protected]>"

# current code's approach
jshell> sampleMail.addCc(multibyteCharAddress);
jshell> sampleMail.getCcAddresses().get(0)
==> "Eva Nováková" <[email protected]>

# this PR's approach
jshell> InternetAddress iAddress = new InternetAddress(multibyteCharAddress);
jshell> sampleMail.addCc(iAddress.getAddress(), iAddress.getPersonal());
jshell> sampleMail.getCcAddresses().get(1)
==> =?UTF-8?Q?Eva_Nov=C3=A1kov=C3=A1?= <[email protected]>

As we can see, in the second example, non-ASCII characters are encoded based on RFC2047.

Without this, our mailer can't know how to decode recipients' addresses, especially when they include some multibyte characters. We sometimes get garbled addresses such as ������ <[email protected]> displayed.

I considered adding tests about this. But I think this problem is rather related to the behavior of Apache Commons' Email class.

Moreover, in this(12 years old) commit, other (From, ReplyTo, and Bcc) addresses already experienced this change. Probably this change list has no bad effect, doesn't it?

to-lz1 avatar Jul 11 '21 10:07 to-lz1

@to-lz1 Yes, I understand that this test seems more like a test for Apache Commons' Email class. But not only. It verifies that Play does use the right library. Anyway, it's better to have such a test than not to have.

asolntsev avatar Jul 12 '21 20:07 asolntsev

@asolntsev
Now that the UT you pointed out has been ready, could you consider merging this PR?

yuba avatar Sep 26 '22 10:09 yuba

@yuba I clicked "Accept" in code review. The last word is usually from @xael-fry - could you please merge this pull request and inform us about release plans?

asolntsev avatar Sep 26 '22 13:09 asolntsev

@xael-fry How about including this PR in release 1.8.0?

yuba avatar Oct 03 '22 03:10 yuba