Commit d5774801 authored by Ezio Melotti's avatar Ezio Melotti

#20977: fix undefined name in the email module. Patch by Rose Ames.

parent 591176e5
...@@ -2897,7 +2897,7 @@ def parse_content_disposition_header(value): ...@@ -2897,7 +2897,7 @@ def parse_content_disposition_header(value):
try: try:
token, value = get_token(value) token, value = get_token(value)
except errors.HeaderParseError: except errors.HeaderParseError:
ctype.defects.append(errors.InvalidHeaderDefect( disp_header.defects.append(errors.InvalidHeaderDefect(
"Expected content disposition but found {!r}".format(value))) "Expected content disposition but found {!r}".format(value)))
_find_mime_parameters(disp_header, value) _find_mime_parameters(disp_header, value)
return disp_header return disp_header
...@@ -2928,8 +2928,8 @@ def parse_content_transfer_encoding_header(value): ...@@ -2928,8 +2928,8 @@ def parse_content_transfer_encoding_header(value):
try: try:
token, value = get_token(value) token, value = get_token(value)
except errors.HeaderParseError: except errors.HeaderParseError:
ctype.defects.append(errors.InvalidHeaderDefect( cte_header.defects.append(errors.InvalidHeaderDefect(
"Expected content trnasfer encoding but found {!r}".format(value))) "Expected content transfer encoding but found {!r}".format(value)))
else: else:
cte_header.append(token) cte_header.append(token)
cte_header.cte = token.value.strip().lower() cte_header.cte = token.value.strip().lower()
......
...@@ -2443,6 +2443,18 @@ class TestParser(TestParserMixin, TestEmailBase): ...@@ -2443,6 +2443,18 @@ class TestParser(TestParserMixin, TestEmailBase):
self.assertEqual(str(address_list.addresses[1]), self.assertEqual(str(address_list.addresses[1]),
str(address_list.mailboxes[2])) str(address_list.mailboxes[2]))
def test_invalid_content_disposition(self):
content_disp = self._test_parse_x(
parser.parse_content_disposition_header,
";attachment", "; attachment", ";attachment",
[errors.InvalidHeaderDefect]*2
)
def test_invalid_content_transfer_encoding(self):
cte = self._test_parse_x(
parser.parse_content_transfer_encoding_header,
";foo", ";foo", ";foo", [errors.InvalidHeaderDefect]*3
)
@parameterize @parameterize
class Test_parse_mime_version(TestParserMixin, TestEmailBase): class Test_parse_mime_version(TestParserMixin, TestEmailBase):
......
...@@ -35,6 +35,7 @@ Billy G. Allie ...@@ -35,6 +35,7 @@ Billy G. Allie
Kevin Altis Kevin Altis
Skyler Leigh Amador Skyler Leigh Amador
Joe Amenta Joe Amenta
Rose Ames
A. Amoroso A. Amoroso
Mark Anacker Mark Anacker
Shashwat Anand Shashwat Anand
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment