]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-30835: email: Fix AttributeError when parsing invalid CTE (GH-13598)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 5 Jun 2019 10:23:37 +0000 (03:23 -0700)
committerGitHub <noreply@github.com>
Wed, 5 Jun 2019 10:23:37 +0000 (03:23 -0700)
commitf62a372928fbf6a2ba722f12f069b75ca6ad16fb
treedff68e8171f97adb917dd6df5062ee167cfb6b4d
parent3d75bd15ac82575967db367c517d7e6e703a6de3
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>
Lib/email/feedparser.py
Lib/test/test_email/test_email.py
Misc/NEWS.d/next/Library/2019-05-27-15-29-46.bpo-30835.3FoaWH.rst [new file with mode: 0644]