New submission from Andrew Donnellan: 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. ---------- components: Library (Lib), email files: testprog.py messages: 297584 nosy: Andrew Donnellan, barry, r.david.murray priority: normal severity: normal status: open title: AttributeError when parsing multipart email with invalid non-decodable Content-Transfer-Encoding type: behavior versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7 Added file: http://bugs.python.org/file46989/testprog.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30835> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com