mirror of https://github.com/django/django.git
Refs #34118 -- Improved sanitize_address() error message for tuple with empty strings.
This commit is contained in:
parent
0016a42995
commit
da2f8e8257
|
@ -97,6 +97,8 @@ def sanitize_address(addr, encoding):
|
|||
domain = token.domain or ""
|
||||
else:
|
||||
nm, address = addr
|
||||
if "@" not in address:
|
||||
raise ValueError(f'Invalid address "{address}"')
|
||||
localpart, domain = address.rsplit("@", 1)
|
||||
|
||||
address_parts = nm + localpart + domain
|
||||
|
|
|
@ -1084,9 +1084,10 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
|||
"@",
|
||||
"to@",
|
||||
"@example.com",
|
||||
("", ""),
|
||||
):
|
||||
with self.subTest(email_address=email_address):
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaisesMessage(ValueError, "Invalid address"):
|
||||
sanitize_address(email_address, encoding="utf-8")
|
||||
|
||||
def test_sanitize_address_header_injection(self):
|
||||
|
|
Loading…
Reference in New Issue