[PATCH 5/9] parser: Handle even more exotically broken headers
andrew.donnellan at au1.ibm.com
Thu Feb 22 14:35:49 AEDT 2018
On 22/02/18 01:17, Daniel Axtens wrote:
> An archive of the Ubuntu kernel team mailing list contains a
> fascinating email that causes the following parse error:
> email.errors.HeaderParseError: header value appears to contain an embedded header:
> '4Mf^tnii7k\\_EnR5aobBm6Di[DZ9 at AX1wJ"okBdX-UoJ>:SRn]c6DDU"qUIwfs98vF>...
> The broken bit seem related to a UTF-8 quoted-printable encoded
> section and to be from an internal attempt to break it over multiple
> lines: here's a snippet from the error message:
> but interesting the header itself does not contain the new lines, so
> clearly something quite weird is happening behind the scenes!
> This only throws on header.encode(): it actually makes it through
> sanitise_header and into find_headers before throwing the assertion.
> So, try to encode in sanitize_header as a final step.
> Also, fix a hilarious* python bug that this exposes: whitespace-only
> headers cause an index error!
> Signed-off-by: Daniel Axtens <dja at axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com IBM Australia Limited
More information about the Patchwork