diff roundup/mailgw.py @ 5761:cacef71b3a54 issue2551008

working branch for fixing https://issues.roundup-tracker.org/issue2551008
author John Rouillard <rouilj@ieee.org>
date Mon, 03 Jun 2019 20:50:58 -0400
parents 081be318661b
children 945051a69d85
line wrap: on
line diff
--- a/roundup/mailgw.py	Sun Jun 02 17:15:23 2019 -0400
+++ b/roundup/mailgw.py	Mon Jun 03 20:50:58 2019 -0400
@@ -204,6 +204,13 @@
         for part, encoding in decode_header(hdr):
             if encoding:
                 part = part.decode(encoding)
+            else:
+                # if the encoding is unknown, try decoding with utf-8
+                # and fallback on iso-8859-1 if that fails
+                try:
+                    part = part.decode('utf-8')
+                except UnicodeDecodeError:
+                    part = part.decode('iso-8859-1')
             # RFC 2047 specifies that between encoded parts spaces are
             # swallowed while at the borders from encoded to non-encoded
             # or vice-versa we must preserve a space. Multiple adjacent

Roundup Issue Tracker: http://roundup-tracker.org/