[Django] #35713: Django generates invalid address on unicode characters in the local part of an e-mail address

13 views
Skip to first unread message

Django

unread,
Aug 27, 2024, 2:24:44 PM8/27/24
to django-...@googlegroups.com
#35713: Django generates invalid address on unicode characters in the local part of
an e-mail address
------------------------------+---------------------------------------
Reporter: Mike Edmunds | Type: Bug
Status: new | Component: Core (Mail)
Version: 5.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------
#25986 attempted to add support for non-ASCII characters in the local-part
(username) of an email address, by encoding it as an RFC 2047 encoded-
word. [https://github.com/django/django/pull/6377 PR#6377] landed in
Django 1.10.

However, RFC 2047
[https://datatracker.ietf.org/doc/html/rfc2047#section-5:~:text=An%20%27encoded%2Dword%27%20MUST%20NOT%20appear%20in%20any%20portion%20of%20an%20%27addr%2Dspec%27.
specifically prohibits] using an encoded-word in an addr-spec (the
username@domain portion of an email address). Encoded-words are only
allowed in address display-names.

The resulting email address is not supported by any known MTA or email
client, and the message will either bounce or just disappear undelivered.

To reproduce:

{{{#!python
from django.core.mail import EmailMessage
email = EmailMessage(to=["jör...@example.no"])
print(email.message().as_bytes().decode()) # examine generated message
# ...
# To: =?utf-8?b?asO2cmc=?=@example.no
# ...
email.send() # if you've set up a mailbox for jörg at example.no
}}}

Actual results: as above (no errors)

Expected results: no `=?utf-8?...` encoded-word in the generated ''To''
addr-spec. And an error on the call to `send()` (or `message()`) saying
that a non-ASCII local-part is not supported.

There is ''no'' supported way to send to non-ASCII usernames using 7-bit
email headers. That requires using 8-bit headers with the SMTPUTF8
extension under RFC 6530/6531/6532. (I'll open a separate feature request
ticket about that; this ticket is solely about removing the current buggy
behavior.)

For more details see
[https://code.djangoproject.com/ticket/25986#comment:12 #25986 comments
12-13].
--
Ticket URL: <https://code.djangoproject.com/ticket/35713>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 28, 2024, 3:17:22 AM8/28/24
to django-...@googlegroups.com
#35713: Django generates invalid address on unicode characters in the local part of
an e-mail address
------------------------------+------------------------------------
Reporter: Mike Edmunds | Owner: (none)
Type: Bug | Status: new
Component: Core (Mail) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Claude Paroz):

* stage: Unreviewed => Accepted
* version: 5.0 => dev

Comment:

Looks legitimate.
--
Ticket URL: <https://code.djangoproject.com/ticket/35713#comment:1>

Django

unread,
Aug 30, 2024, 4:34:21 AM8/30/24
to django-...@googlegroups.com
#35713: Django generates invalid address on unicode characters in the local part of
an e-mail address
------------------------------+---------------------------------------
Reporter: Mike Edmunds | Owner: YashRaj1506
Type: Bug | Status: assigned
Component: Core (Mail) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------
Changes (by YashRaj1506):

* owner: (none) => YashRaj1506
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35713#comment:2>

Django

unread,
Sep 3, 2024, 5:11:46 PM9/3/24
to django-...@googlegroups.com
#35713: Django generates invalid address on unicode characters in the local part of
an e-mail address
------------------------------+---------------------------------------
Reporter: Mike Edmunds | Owner: YashRaj1506
Type: Bug | Status: assigned
Component: Core (Mail) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------
Description changed by Mike Edmunds:

Old description:

> #25986 attempted to add support for non-ASCII characters in the local-
> part (username) of an email address, by encoding it as an RFC 2047
> encoded-word. [https://github.com/django/django/pull/6377 PR#6377] landed
New description:
extension under RFC 6530/6531/6532. (That new feature request is ticket
#35714; this ticket is solely about removing the current buggy behavior.)

For more details see
[https://code.djangoproject.com/ticket/25986#comment:12 #25986 comments
12-13].

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35713#comment:3>

Django

unread,
Sep 5, 2024, 1:11:26 AM9/5/24
to django-...@googlegroups.com
#35713: Django generates invalid address on unicode characters in the local part of
an e-mail address
------------------------------+------------------------------------
Reporter: Mike Edmunds | Owner: (none)
Type: Bug | Status: new
Component: Core (Mail) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by YashRaj1506):

* owner: YashRaj1506 => (none)
* status: assigned => new

--
Ticket URL: <https://code.djangoproject.com/ticket/35713#comment:4>

Django

unread,
Sep 5, 2024, 12:45:46 PM9/5/24
to django-...@googlegroups.com
#35713: Django generates invalid address on unicode characters in the local part of
an e-mail address
------------------------------+------------------------------------
Reporter: Mike Edmunds | Owner: (none)
Type: Bug | Status: new
Component: Core (Mail) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Comment (by Mike Edmunds):

The proposed patch for #35581 will
[https://github.com/medmunds/django/blob/efbc7c8cfb858286f573ea8af6dc264b4709a1a9/tests/mail/tests.py#L2406-L2418
raise an error for non-ASCII local-parts] in `send()` when using the SMTP
EmailBackend.

Catching the error earlier, in `message()`, would require additional work.
--
Ticket URL: <https://code.djangoproject.com/ticket/35713#comment:5>

Django

unread,
Sep 11, 2024, 12:48:02 PM9/11/24
to django-...@googlegroups.com
#35713: Django generates invalid address on unicode characters in the local part of
an e-mail address
------------------------------+----------------------------------------
Reporter: Mike Edmunds | Owner: Vaibhav Pant
Type: Bug | Status: assigned
Component: Core (Mail) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Vaibhav Pant):

* owner: (none) => Vaibhav Pant
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35713#comment:6>
Reply all
Reply to author
Forward
0 new messages