From 43e481a5532361a762e6543df23ed8fc88800976 Mon Sep 17 00:00:00 2001 From: oda-gitso Date: Fri, 20 May 2022 20:48:02 +0700 Subject: [PATCH 1/8] fix issue 93010 --- Lib/email/_header_value_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index 8a8fb8bc42a954..e637e6df06612d 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -2379,7 +2379,7 @@ def get_section(value): digits += value[0] value = value[1:] if digits[0] == '0' and digits != '0': - section.defects.append(errors.InvalidHeaderError( + section.defects.append(errors.InvalidHeaderDefect( "section number has an invalid leading 0")) section.number = int(digits) section.append(ValueTerminal(digits, 'digits')) From 131f7d205928db8ebd862a31a42394ca4d672c08 Mon Sep 17 00:00:00 2001 From: oda-gitso Date: Fri, 20 May 2022 22:46:51 +0700 Subject: [PATCH 2/8] gh-93010 added test case --- Lib/test/test_email/test_email.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 69f883a3673f26..db7e9b1aca5975 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -31,6 +31,7 @@ from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.nonmultipart import MIMENonMultipart +from email.headerregistry import HeaderRegistry from email import utils from email import errors from email import encoders @@ -5541,7 +5542,11 @@ def test_long_headers_flatten(self): result = fp.getvalue() self._signed_parts_eq(original, result) - +class TestHeaderRegistry(TestEmailBase): + # See issue 93010. + def test_HeaderRegistry(self): + reg = HeaderRegistry() + reg('Content-Disposition', 'attachment; 0*00="foo"') if __name__ == '__main__': unittest.main() From ffcc4857bf18dd3d84d7af90f5ba4794c76768fa Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 20 May 2022 15:52:44 +0000 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst diff --git a/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst b/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst new file mode 100644 index 00000000000000..19f63ba51bd57e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst @@ -0,0 +1 @@ +In a very special case, the email package would raise, errors.InvalidHeaderError, which is nonexistent. errors.InvalidHeaderError has been replaced by errors.InvalidHeaderDefect. From 55f0519bc3f46a1fbe2b2c8d19ee94c892f02ae5 Mon Sep 17 00:00:00 2001 From: oda-gitso <105083118+oda-gitso@users.noreply.github.com> Date: Sat, 21 May 2022 00:10:27 +0700 Subject: [PATCH 4/8] Update 2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst --- .../next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst b/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst index 19f63ba51bd57e..f46152dabf326c 100644 --- a/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst +++ b/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst @@ -1 +1 @@ -In a very special case, the email package would raise, errors.InvalidHeaderError, which is nonexistent. errors.InvalidHeaderError has been replaced by errors.InvalidHeaderDefect. +In a very special case, the email package tried to append the nonexistent InvalidHeaderError to the defect list. It should have been InvalidHeaderDefect. From 031afa03ea769af327a4ae87dbaa557f7b9327cf Mon Sep 17 00:00:00 2001 From: oda-gitso <105083118+oda-gitso@users.noreply.github.com> Date: Sat, 21 May 2022 00:11:54 +0700 Subject: [PATCH 5/8] Update test_email.py --- Lib/test/test_email/test_email.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index db7e9b1aca5975..388b510379861a 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -5543,7 +5543,7 @@ def test_long_headers_flatten(self): self._signed_parts_eq(original, result) class TestHeaderRegistry(TestEmailBase): - # See issue 93010. + # See issue gh-93010. def test_HeaderRegistry(self): reg = HeaderRegistry() reg('Content-Disposition', 'attachment; 0*00="foo"') From d88f7f50de0435601772146ed11cac0d80e64ee8 Mon Sep 17 00:00:00 2001 From: oda-gitso <105083118+oda-gitso@users.noreply.github.com> Date: Sat, 21 May 2022 00:23:23 +0700 Subject: [PATCH 6/8] Update test_email.py --- Lib/test/test_email/test_email.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 388b510379861a..4159de2f879627 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -19,25 +19,25 @@ import email.policy from email.charset import Charset -from email.header import Header, decode_header, make_header -from email.parser import Parser, HeaderParser from email.generator import Generator, DecodedGenerator, BytesGenerator +from email.header import Header, decode_header, make_header +from email.headerregistry import HeaderRegistry from email.message import Message from email.mime.application import MIMEApplication from email.mime.audio import MIMEAudio -from email.mime.text import MIMEText -from email.mime.image import MIMEImage from email.mime.base import MIMEBase +from email.mime.image import MIMEImage from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.nonmultipart import MIMENonMultipart -from email.headerregistry import HeaderRegistry -from email import utils -from email import errors +from email.mime.text import MIMEText +from email.parser import Parser, HeaderParser +from email import base64mime from email import encoders +from email import errors from email import iterators -from email import base64mime from email import quoprimime +from email import utils from test.support import threading_helper from test.support.os_helper import unlink From 7d66836b0dc37f480ad47e5294b5924bc6e68fa9 Mon Sep 17 00:00:00 2001 From: oda-gitso <105083118+oda-gitso@users.noreply.github.com> Date: Sat, 21 May 2022 00:26:57 +0700 Subject: [PATCH 7/8] Update 2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst --- .../next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst b/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst index f46152dabf326c..24208b5160ed52 100644 --- a/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst +++ b/Misc/NEWS.d/next/Library/2022-05-20-15-52-43.gh-issue-93010.WF-cAc.rst @@ -1 +1 @@ -In a very special case, the email package tried to append the nonexistent InvalidHeaderError to the defect list. It should have been InvalidHeaderDefect. +In a very special case, the email package tried to append the nonexistent ``InvalidHeaderError`` to the defect list. It should have been ``InvalidHeaderDefect``. From 43985e05582bbe9bac32b1c9d44598b570f09af3 Mon Sep 17 00:00:00 2001 From: oda-gitso <105083118+oda-gitso@users.noreply.github.com> Date: Sat, 21 May 2022 00:55:53 +0700 Subject: [PATCH 8/8] Update test_email.py --- Lib/test/test_email/test_email.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 4159de2f879627..2b1e2b864feda1 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -5546,7 +5546,8 @@ class TestHeaderRegistry(TestEmailBase): # See issue gh-93010. def test_HeaderRegistry(self): reg = HeaderRegistry() - reg('Content-Disposition', 'attachment; 0*00="foo"') + a = reg('Content-Disposition', 'attachment; 0*00="foo"') + self.assertIsInstance(a.defects[0], errors.InvalidHeaderDefect) if __name__ == '__main__': unittest.main()