[PATCH 01/10] parser: fix charset 'guessing' algorithm

Daniel Axtens dja at axtens.net
Wed Jun 28 17:48:43 AEST 2017


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 at axtens.net>
---
 patchwork/parser.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/patchwork/parser.py b/patchwork/parser.py
index 794a5eac2d29..4903aa8237e6 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -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:
-- 
2.11.0



More information about the Patchwork mailing list