]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parser: codec lookup fails when a NUL (\x00) is in the name
authorDaniel Axtens <dja@axtens.net>
Wed, 28 Jun 2017 07:48:45 +0000 (17:48 +1000)
committerStephen Finucane <stephen@that.guru>
Wed, 28 Jun 2017 20:41:28 +0000 (21:41 +0100)
On Python3 this presents as a ValueError
On Python2 this presents as a TypeError

In both cases, catch these exceptions.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/parser.py

index f9934cc1e33eceefc0273340d33e05d30fe150d8..534e92c776429ce6706e193a1f4e8ec05fa88f7c 100644 (file)
@@ -436,7 +436,7 @@ def _find_content(mail):
             if charset is not None:
                 try:
                     codecs.lookup(charset)
-                except LookupError:
+                except (LookupError, ValueError, TypeError):
                     charset = None
 
             # If there is no charset or if it is unknown, then try some common