1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

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.
This commit is contained in:
Carlton Gibson 2019-06-13 16:39:00 +02:00 committed by Carlton Gibson
parent 2628ea9515
commit 1564e42ad3

View File

@ -716,6 +716,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
'utf-8', 'utf-8',
'=?utf-8?q?A_name?= <to@example.com>', '=?utf-8?q?A_name?= <to@example.com>',
), ),
('localpartonly', 'ascii', 'localpartonly'),
# ASCII addresses with display names. # ASCII addresses with display names.
('A name <to@example.com>', 'ascii', 'A name <to@example.com>'), ('A name <to@example.com>', 'ascii', 'A name <to@example.com>'),
('A name <to@example.com>', 'utf-8', '=?utf-8?q?A_name?= <to@example.com>'), ('A name <to@example.com>', 'utf-8', '=?utf-8?q?A_name?= <to@example.com>'),