Author martin.panter
Recipients Lukasa, barry, demian.brecht, icordasc, martin.panter, mgdelmonte, piotr.dobrogost, r.david.murray
Date 2015-11-29.01:24:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448760257.84.0.0114345750107.issue24363@psf.upfronthosting.co.za>
In-reply-to
Content
Since the Python 2 and Python 3 branches are different, two different patches would be needed here. Perhaps they could share common test cases though.

Michael: I presume your proposal is for Python 2. I don’t understand the re.findall() expression; is there a clearer way to do whatever it is trying to do (or failing that, explain it in a comment)? It looks like you are trying to skip over spaces at the start of the first header field name. Also, it seems to drop support for lines folded with tabs rather than spaces.

David: The headers-only mode wouldn’t make much difference because it only affects parsing the “payload”. As far as the email package is concerned, the payload should always be empty when used by HTTP’s parse_headers().

The simplest fix (at least for the Python 3 code) would be to check each line against email.feedparser.headerRE before adding it to the list of lines in the HTTP package. This would prevent the email parser from bailing from the header section early, which is the main problem.

But that does seem like a bad hack and wouldn’t treat the offending line as a folded line, which Cory and David want. So I guess we need to make the email parser more flexible instead. Maybe a private FeedParser._parse_header_lines() method or something, that replaces feed() and close(), and defers most of the processing directly to _parse_headers().
History
Date User Action Args
2015-11-29 01:24:18martin.pantersetrecipients: + martin.panter, barry, r.david.murray, piotr.dobrogost, icordasc, demian.brecht, Lukasa, mgdelmonte
2015-11-29 01:24:17martin.pantersetmessageid: <1448760257.84.0.0114345750107.issue24363@psf.upfronthosting.co.za>
2015-11-29 01:24:17martin.panterlinkissue24363 messages
2015-11-29 01:24:15martin.pantercreate