From d577480197f7cc427ac75deaebae3106399a9cd3 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Mon, 4 Aug 2014 17:16:49 +0300 Subject: #20977: fix undefined name in the email module. Patch by Rose Ames. --- Lib/email/_header_value_parser.py | 6 +++--- Lib/test/test_email/test__header_value_parser.py | 12 ++++++++++++ Misc/ACKS | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index 3dc5502..1806cac 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -2897,7 +2897,7 @@ def parse_content_disposition_header(value): try: token, value = get_token(value) except errors.HeaderParseError: - ctype.defects.append(errors.InvalidHeaderDefect( + disp_header.defects.append(errors.InvalidHeaderDefect( "Expected content disposition but found {!r}".format(value))) _find_mime_parameters(disp_header, value) return disp_header @@ -2928,8 +2928,8 @@ def parse_content_transfer_encoding_header(value): try: token, value = get_token(value) except errors.HeaderParseError: - ctype.defects.append(errors.InvalidHeaderDefect( - "Expected content trnasfer encoding but found {!r}".format(value))) + cte_header.defects.append(errors.InvalidHeaderDefect( + "Expected content transfer encoding but found {!r}".format(value))) else: cte_header.append(token) cte_header.cte = token.value.strip().lower() diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py index 32996ca..5404d19 100644 --- a/Lib/test/test_email/test__header_value_parser.py +++ b/Lib/test/test_email/test__header_value_parser.py @@ -2443,6 +2443,18 @@ class TestParser(TestParserMixin, TestEmailBase): self.assertEqual(str(address_list.addresses[1]), 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 class Test_parse_mime_version(TestParserMixin, TestEmailBase): diff --git a/Misc/ACKS b/Misc/ACKS index fdf89d4..87a3264 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -35,6 +35,7 @@ Billy G. Allie Kevin Altis Skyler Leigh Amador Joe Amenta +Rose Ames A. Amoroso Mark Anacker Shashwat Anand -- cgit v0.12