Fixed #30608 -- Fixed non-unicode EmailMessage crash when domain name for localhost is non-ASCII.#11532
Conversation
|
@ewjoachim Can you take a look? |
ewjoachim
left a comment
There was a problem hiding this comment.
Looks good.
Is it a regression from the patch we merged the other day or a whole new bug ? I'm guessing this is new.
BTW, this whole "punycoding domain names in case they're not punycode" looks a lot like
django/django/core/mail/message.py
Lines 105 to 108 in 2628ea9
And finally, that was nice thinking of me to review this, and just to say it explicitly, feel free to continue doing that.
|
@ewjoachim I believe it is new. I only discovered it because I have a bit of a strange configuration on my computer and have a unicode hostname set. |
|
@ewjoachim Thanks for the review 👍 Yes, it is an old 🐛. I pinged you because you've recently sent PR in this area. Thanks for offering yourself for the future. |
|
I rebased from master and added |
|
since "idna" encodes in ascii anyway, instead of doing a try/except would it make sense to just run the "idna" encode on everything? |
|
@charettes @chason Thanks, I updated PR. |
… for localhost is non-ASCII. Assisted by felixxm.
|
@chason Thanks again 🚀 Welcome aboard ⛵ |
When sending out an email, Django attaches the domain name as part
of the Message-ID header. This was causing an error when the domain
name contains unicode characters and the message is set to an
encoding that cannot encode them. These domains should probably
always be set to encode to punycode in any case, so this patch
changes the CachedDnsName class in django.core.mail.utils to return
this fqdn as punycode when it can't be encoded as ascii.
Assisted by felixxm