diff options
author | Joachim Jablon <joachim.jablon@people-doc.com> | 2019-06-06 14:47:03 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-06-06 15:05:56 +0200 |
commit | 8ba20d9071e9e1b8f2c81d4df977db4278342085 (patch) | |
tree | e52c191a14ba9727fa64bb742c66ba179b066fe2 /tests/mail | |
parent | f841a776feb2b0522c7a919f7355002b8762731a (diff) | |
download | django-8ba20d9071e9e1b8f2c81d4df977db4278342085.tar.gz |
Refs #30512 -- Added tests for sanitizing email addresses with display name and two @ signs.
Diffstat (limited to 'tests/mail')
-rw-r--r-- | tests/mail/tests.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/mail/tests.py b/tests/mail/tests.py index ed1af26953..0a2db39d64 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -716,13 +716,38 @@ class MailTests(HeadersCheckMixin, SimpleTestCase): 'utf-8', '=?utf-8?q?A_name?= <to@example.com>', ), + # ASCII addresses with display names. + ('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>', 'ascii', 'A name <to@example.com>'), + ('"A name" <to@example.com>', 'utf-8', '=?utf-8?q?A_name?= <to@example.com>'), # Unicode addresses (supported per RFC-6532). ('tó@example.com', 'utf-8', '=?utf-8?b?dMOz?=@example.com'), + ('to@éxample.com', 'utf-8', 'to@xn--xample-9ua.com'), ( ('Tó Example', 'tó@example.com'), 'utf-8', '=?utf-8?q?T=C3=B3_Example?= <=?utf-8?b?dMOz?=@example.com>', ), + # Unicode addresses with display names. + ( + 'Tó Example <tó@example.com>', + 'utf-8', + '=?utf-8?q?T=C3=B3_Example?= <=?utf-8?b?dMOz?=@example.com>', + ), + ('To Example <to@éxample.com>', 'ascii', 'To Example <to@xn--xample-9ua.com>'), + ( + 'To Example <to@éxample.com>', + 'utf-8', + '=?utf-8?q?To_Example?= <to@xn--xample-9ua.com>', + ), + # Addresses with two @ signs. + ('"to@other.com"@example.com', 'utf-8', r'"to@other.com"@example.com'), + ( + '"to@other.com" <to@example.com>', + 'utf-8', + '=?utf-8?q?to=40other=2Ecom?= <to@example.com>', + ), ): with self.subTest(email_address=email_address, encoding=encoding): self.assertEqual(sanitize_address(email_address, encoding), expected_result) |