]> git.ipfire.org Git - thirdparty/patchwork.git/commit
parser: parse headers containing invalid characters or codings
authorDaniel Axtens <dja@axtens.net>
Mon, 19 Sep 2016 14:23:58 +0000 (00:23 +1000)
committerStephen Finucane <stephen@that.guru>
Sat, 8 Oct 2016 19:42:33 +0000 (20:42 +0100)
commit6703cb52f9338cf502b6b4167aacb8d3bdf7d69e
tree8ae251e183d2708595fc1d7c36367a1bf19b0319
parente073ca7900a2d9ba0db75cb49efb4e79bf37f475
parser: parse headers containing invalid characters or codings

If there is a non-ascii character in a header, parsing fails,
even on Py27.

This has huge Py2/Py3 complexities. The Py3 email package has tools
to handle this - we just need to use them. Py2, on the other hand,
needs a lot of hand-holding, as explained in the comments.

Additionally, support headers that claim an encoding, but fail to
decode with that encoding.

This is handy for mails with malformed headers containing weird
bytes.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reported-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
(cherry picked from commit 6625d4b0dcdf1820b73227c40118625d4db9e130)
patchwork/bin/parsemail.py