diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-06-05 03:23:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-05 03:23:37 -0700 |
commit | f62a372928fbf6a2ba722f12f069b75ca6ad16fb (patch) | |
tree | dff68e8171f97adb917dd6df5062ee167cfb6b4d /Misc | |
parent | 3d75bd15ac82575967db367c517d7e6e703a6de3 (diff) | |
download | cpython-git-f62a372928fbf6a2ba722f12f069b75ca6ad16fb.tar.gz |
bpo-30835: email: Fix AttributeError when parsing invalid CTE (GH-13598)
* bpo-30835: email: Fix AttributeError when parsing invalid Content-Transfer-Encoding
Parsing an email containing a multipart Content-Type, along with a
Content-Transfer-Encoding containing an invalid (non-ASCII-decodable) byte
will fail. email.feedparser.FeedParser._parsegen() gets the header and
attempts to convert it to lowercase before comparing it with the accepted
encodings, but as the header contains an invalid byte, it's returned as a
Header object rather than a str.
Cast the Content-Transfer-Encoding header to a str to avoid this.
Found using the AFL fuzzer.
Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Andrew Donnellan <andrew@donnellan.id.au>
* Add email and NEWS entry for the bugfix.
(cherry picked from commit aa79707262f893428665ef45b5e879129abca4aa)
Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Library/2019-05-27-15-29-46.bpo-30835.3FoaWH.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2019-05-27-15-29-46.bpo-30835.3FoaWH.rst b/Misc/NEWS.d/next/Library/2019-05-27-15-29-46.bpo-30835.3FoaWH.rst new file mode 100644 index 0000000000..019321d6f1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-05-27-15-29-46.bpo-30835.3FoaWH.rst @@ -0,0 +1,3 @@ +Fixed a bug in email parsing where a message with invalid bytes in +content-transfer-encoding of a multipart message can cause an AttributeError. +Patch by Andrew Donnellan. |