mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #35497: Header
maxlinelen
is set to equal RFC5332 email line length limit.
This commit is contained in:
parent
6efbeb997c
commit
5fa1fb9a96
@ -108,13 +108,15 @@ def sanitize_address(addr, encoding):
|
|||||||
# Avoid UTF-8 encode, if it's possible.
|
# Avoid UTF-8 encode, if it's possible.
|
||||||
try:
|
try:
|
||||||
nm.encode("ascii")
|
nm.encode("ascii")
|
||||||
nm = Header(nm).encode()
|
nm = Header(nm, None, RFC5322_EMAIL_LINE_LENGTH_LIMIT).encode()
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
nm = Header(nm, encoding).encode()
|
nm = Header(nm, encoding, RFC5322_EMAIL_LINE_LENGTH_LIMIT).encode()
|
||||||
try:
|
try:
|
||||||
localpart.encode("ascii")
|
localpart.encode("ascii")
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
localpart = Header(localpart, encoding).encode()
|
localpart = Header(
|
||||||
|
localpart, encoding, RFC5322_EMAIL_LINE_LENGTH_LIMIT
|
||||||
|
).encode()
|
||||||
domain = punycode(domain)
|
domain = punycode(domain)
|
||||||
|
|
||||||
parsed_address = Address(username=localpart, domain=domain)
|
parsed_address = Address(username=localpart, domain=domain)
|
||||||
|
@ -1079,25 +1079,28 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
|||||||
"Tó Example very long" * 4 + " <to@example.com>",
|
"Tó Example very long" * 4 + " <to@example.com>",
|
||||||
"utf-8",
|
"utf-8",
|
||||||
"=?utf-8?q?T=C3=B3_Example_very_longT=C3=B3_Example_very_longT"
|
"=?utf-8?q?T=C3=B3_Example_very_longT=C3=B3_Example_very_longT"
|
||||||
"=C3=B3_Example_?=\n"
|
"=C3=B3_Example_very_longT=C3=B3_Example_very_long?= "
|
||||||
" =?utf-8?q?very_longT=C3=B3_Example_very_long?= "
|
|
||||||
"<to@example.com>",
|
"<to@example.com>",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
("Tó Example very long" * 4, "to@example.com"),
|
("Tó Example very long" * 4, "to@example.com"),
|
||||||
"utf-8",
|
"utf-8",
|
||||||
"=?utf-8?q?T=C3=B3_Example_very_longT=C3=B3_Example_very_longT"
|
"=?utf-8?q?T=C3=B3_Example_very_longT=C3=B3_Example_very_longT"
|
||||||
"=C3=B3_Example_?=\n"
|
"=C3=B3_Example_very_longT=C3=B3_Example_very_long?= "
|
||||||
" =?utf-8?q?very_longT=C3=B3_Example_very_long?= "
|
|
||||||
"<to@example.com>",
|
"<to@example.com>",
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"ţēśţ." * 6 + "@example.com",
|
||||||
|
"utf-8",
|
||||||
|
"=?utf-8?b?xaPEk8WbxaMuxaPEk8WbxaMuxaPEk8WbxaMuxaPEk8WbxaMuxa"
|
||||||
|
"PEk8WbxaMuxaPEk8WbxaMu?=@example.com",
|
||||||
|
),
|
||||||
# Address with long display name and unicode domain.
|
# Address with long display name and unicode domain.
|
||||||
(
|
(
|
||||||
("To Example very long" * 4, "to@exampl€.com"),
|
("To Example very long" * 4, "to@exampl€.com"),
|
||||||
"utf-8",
|
"utf-8",
|
||||||
"To Example very longTo Example very longTo Example very longT"
|
"To Example very longTo Example very longTo Example very longT"
|
||||||
"o Example very\n"
|
"o Example very long <to@xn--exampl-nc1c.com>",
|
||||||
" long <to@xn--exampl-nc1c.com>",
|
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
with self.subTest(email_address=email_address, encoding=encoding):
|
with self.subTest(email_address=email_address, encoding=encoding):
|
||||||
|
Loading…
Reference in New Issue
Block a user