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?= ', ), + # ASCII addresses with display names. + ('A name ', 'ascii', 'A name '), + ('A name ', 'utf-8', '=?utf-8?q?A_name?= '), + ('"A name" ', 'ascii', 'A name '), + ('"A name" ', 'utf-8', '=?utf-8?q?A_name?= '), # 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 ', + 'utf-8', + '=?utf-8?q?T=C3=B3_Example?= <=?utf-8?b?dMOz?=@example.com>', + ), + ('To Example ', 'ascii', 'To Example '), + ( + 'To Example ', + 'utf-8', + '=?utf-8?q?To_Example?= ', + ), + # Addresses with two @ signs. + ('"to@other.com"@example.com', 'utf-8', r'"to@other.com"@example.com'), + ( + '"to@other.com" ', + 'utf-8', + '=?utf-8?q?to=40other=2Ecom?= ', + ), ): with self.subTest(email_address=email_address, encoding=encoding): self.assertEqual(sanitize_address(email_address, encoding), expected_result)