[Django] #30512: Update mail backend to use modern standard library parsing approach

12 views
Skip to first unread message

Django

unread,
May 26, 2019, 12:28:45 PM5/26/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach
-------------------------------------+-------------------------------------
Reporter: Joachim | Owner: Joachim Jablon
Jablon |
Type: | Status: assigned
Cleanup/optimization |
Component: Core | Version: master
(Mail) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{ django.core.mail.message.sanitize_address }}} uses {{{
email.utils.parseaddr }}} from the standard lib. On Python 3, {{{
email.headerregistry.parser.get_mailbox() }}} does the same, and is less
error-prone.

--
Ticket URL: <https://code.djangoproject.com/ticket/30512>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 26, 2019, 1:35:36 PM5/26/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach
-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Joachim Jablon):

* has_patch: 0 => 1


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

Django

unread,
May 27, 2019, 1:39:36 AM5/27/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach.

-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Unreviewed => Accepted


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

Django

unread,
Jun 6, 2019, 9:28:06 AM6/6/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach.
-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"f841a776feb2b0522c7a919f7355002b8762731a" f841a77]:
{{{
#!CommitTicketReference repository=""
revision="f841a776feb2b0522c7a919f7355002b8762731a"
Refs #30512 -- Used subTest() in MailTests.test_sanitize_address.
}}}

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

Django

unread,
Jun 6, 2019, 9:28:08 AM6/6/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach.
-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"8ba20d9071e9e1b8f2c81d4df977db4278342085" 8ba20d90]:
{{{
#!CommitTicketReference repository=""
revision="8ba20d9071e9e1b8f2c81d4df977db4278342085"
Refs #30512 -- Added tests for sanitizing email addresses with display
name and two @ signs.
}}}

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

Django

unread,
Jun 12, 2019, 9:57:26 AM6/12/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach.
-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30512#comment:5>

Django

unread,
Jun 13, 2019, 1:14:08 AM6/13/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach.
-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/30512#comment:6>

Django

unread,
Jun 13, 2019, 2:19:02 AM6/13/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach.
-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30512#comment:7>

Django

unread,
Jun 13, 2019, 10:23:29 AM6/13/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach.
-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: closed

Component: Core (Mail) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"2628ea95151feb68f43a2a740e6fb0799a94b14b" 2628ea95]:
{{{
#!CommitTicketReference repository=""
revision="2628ea95151feb68f43a2a740e6fb0799a94b14b"
Fixed #30512 -- Used email.headerregistry.parser for parsing emails in
sanitize_address().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30512#comment:8>

Django

unread,
Jun 13, 2019, 11:30:51 AM6/13/19
to django-...@googlegroups.com
#30512: Update mail backend to use modern standard library parsing approach.
-------------------------------------+-------------------------------------
Reporter: Joachim Jablon | Owner: Joachim
Type: | Jablon
Cleanup/optimization | Status: closed
Component: Core (Mail) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton@…>):

In [changeset:"1564e42ad397021093585147875a21dae1a3b3fc" 1564e42a]:
{{{
#!CommitTicketReference repository=""
revision="1564e42ad397021093585147875a21dae1a3b3fc"
Refs #30512, #15042 -- Added local-only address to sanitize_email() tests
cases.

email.headerregistry.parser.get_mailbox() returns a token with a
`token_type` attribute.

If `token_type` is `’invalid-mailbox’` then RFC violations have been
detected. Emails with only the local part, and no domain, are correctly
parsed but are marked as `’invalid-mailbox’`.

As per #15042, local-only are supported, to enable sending to addresses on
localhost.

sanitize_email() does not currently check `token_type`. This test is added
to avoid a regression in case this is revisited in the future.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30512#comment:9>

Reply all
Reply to author
Forward
0 new messages