mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fixed #30512 -- Used email.headerregistry.parser for parsing emails in sanitize_address().
This commit is contained in:
parent
0c2ffdd526
commit
2628ea9515
2 changed files with 53 additions and 45 deletions
|
@ -748,10 +748,30 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
|||
'utf-8',
|
||||
'=?utf-8?q?to=40other=2Ecom?= <to@example.com>',
|
||||
),
|
||||
(
|
||||
('To Example', 'to@other.com@example.com'),
|
||||
'utf-8',
|
||||
'=?utf-8?q?To_Example?= <"to@other.com"@example.com>',
|
||||
),
|
||||
):
|
||||
with self.subTest(email_address=email_address, encoding=encoding):
|
||||
self.assertEqual(sanitize_address(email_address, encoding), expected_result)
|
||||
|
||||
def test_sanitize_address_invalid(self):
|
||||
for email_address in (
|
||||
# Invalid address with two @ signs.
|
||||
'to@other.com@example.com',
|
||||
# Invalid address without the quotes.
|
||||
'to@other.com <to@example.com>',
|
||||
# Other invalid addresses.
|
||||
'@',
|
||||
'to@',
|
||||
'@example.com',
|
||||
):
|
||||
with self.subTest(email_address=email_address):
|
||||
with self.assertRaises(ValueError):
|
||||
sanitize_address(email_address, encoding='utf-8')
|
||||
|
||||
|
||||
@requires_tz_support
|
||||
class MailTimeZoneTests(SimpleTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue