]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parser: fix charset 'guessing' algorithm
authorDaniel Axtens <dja@axtens.net>
Wed, 28 Jun 2017 07:48:43 +0000 (17:48 +1000)
committerStephen Finucane <stephen@that.guru>
Wed, 28 Jun 2017 20:41:28 +0000 (21:41 +0100)
The charset guessing algorithm doesn't work if it has to guess
multiple charsets, as it overwrites the payload with None.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/parser.py

index b6c8047d16ecaf0d337cccfef27e9e697c1623b3..cfd77140699ae4f0a218036189ede3abd5ce3c80 100644 (file)
@@ -448,10 +448,11 @@ def _find_content(mail):
 
             for cset in try_charsets:
                 try:
-                    payload = six.text_type(payload, cset)
+                    new_payload = six.text_type(payload, cset)
                     break
                 except UnicodeDecodeError:
-                    payload = None
+                    new_payload = None
+            payload = new_payload
 
             # Could not find a valid decoded payload.  Fail.
             if payload is None: