Author Andrew Donnellan
Recipients Andrew Donnellan, barry, r.david.murray
Date 2017-07-03.13:37:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1499089023.06.0.76757916564.issue30835@psf.upfronthosting.co.za>
In-reply-to
Content
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() calls "self._cur.get('content-transfer-encoding', '8bit')" to get the header.

It then tries to check whether the C-T-E is in the allowable set of ('7bit', '8bit', 'binary'), and to do so case-insensitively, it tries to convert the header to lowercase. However, because there's an invalid character in there, it's dealing with a Header object rather than a str. Hence it throws an AttributeError.

Correct behaviour would be to convert the Header to a str, see that it's not valid, and continue on to handle the defect as usual.

Thanks to Daniel Axtens for finding this bug as he was running the AFL fuzzer on the email parsing code in Patchwork (https://github.com/getpatchwork/patchwork).

Pull request incoming.
History
Date User Action Args
2017-07-03 13:37:03Andrew Donnellansetrecipients: + Andrew Donnellan, barry, r.david.murray
2017-07-03 13:37:03Andrew Donnellansetmessageid: <1499089023.06.0.76757916564.issue30835@psf.upfronthosting.co.za>
2017-07-03 13:37:02Andrew Donnellanlinkissue30835 messages
2017-07-03 13:37:02Andrew Donnellancreate