diff roundup/mailgw.py @ 4575:c426cb251bc7

Be more tolerant when parsing RFC2047 encoded mail headers. Use backported version of my proposed changes to email.header.decode_header in http://bugs.python.org/issue1079
author Ralf Schlatterbeck <rsc@runtux.com>
date Wed, 04 Jan 2012 18:55:49 +0100
parents 8b2ccf6f2cf7
children ba4c632143f6
line wrap: on
line diff
--- a/roundup/mailgw.py	Wed Dec 21 11:25:40 2011 +0100
+++ b/roundup/mailgw.py	Wed Jan 04 18:55:49 2012 +0100
@@ -82,7 +82,7 @@
 import time, random, sys, logging
 import traceback, rfc822
 
-from email.Header import decode_header
+from anypy.email_ import decode_header
 
 from roundup import configuration, hyperdb, date, password, rfc2822, exceptions
 from roundup.mailer import Mailer, MessageSendError
@@ -244,17 +244,14 @@
 
     def _decode_header_to_utf8(self, hdr):
         l = []
-        prev_encoded = False
         for part, encoding in decode_header(hdr):
             if encoding:
                 part = part.decode(encoding)
             # 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
-            # non-encoded parts should not occur.
-            if l and prev_encoded != bool(encoding):
-                l.append(' ')
-            prev_encoded = bool(encoding)
+            # non-encoded parts should not occur. This is now
+            # implemented in our patched decode_header method in anypy
             l.append(part)
         return ''.join([s.encode('utf-8') for s in l])
 

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