[Mailman-Users] patch for Re: problems with different chatsets

Tokio Kikuchi tkikuchi at is.kochi-u.ac.jp
Wed Jan 8 03:47:18 CET 2003


Hi Folks,

I've been reading -users with digest option. So, forgive me for
cutting the thread. Since the patch manager of SF is not allowing
to upload a new patch now, I send this to the list. (sorry, if
it's folded)

With this patch, Decorate.py will try to make the footer and header
in a plain text message by converting the three into unicode and
then encode in a appropriate (defined by mailman) charset.

Hope it helps!

--
Tokio Kikuchi

---
/home/mailman/src/Release_2_1-maint/mailman/Mailman/Handlers/Decorate.py
Wed Jan  8 11:13:38 2003
+++ Decorate.py	Wed Jan  8 11:26:51 2003
@@ -78,17 +78,27 @@
     # MIME multipart chroming the message?
     wrap = 1
     if not msg.is_multipart() and msgtype == 'text/plain' and \
-           msg.get('content-transfer-encoding', '').lower() <>
'base64' and \
-           (lcset == 'us-ascii' or mcset == lcset):
-        oldpayload = msg.get_payload()
-        frontsep = endsep = ''
-        if header and not header.endswith('\n'):
-            frontsep = '\n'
-        if footer and not oldpayload.endswith('\n'):
-            endsep = '\n'
-        payload = header + frontsep + oldpayload + endsep + footer
-        msg.set_payload(payload)
-        wrap = 0
+           msg.get('content-transfer-encoding', '').lower() <> 'base64':
+        # TK: Try to keep the message plain by converting the header/
+        # footer/oldpayload into unicode and encode with mcset/lcset.
+        uheader = unicode(header, lcset)
+        ufooter = unicode(footer, lcset)
+        try:
+            oldpayload = unicode(msg.get_payload(), mcset)
+            frontsep = endsep = u''
+            if header and not header.endswith('\n'):
+                frontsep = u'\n'
+            if footer and not oldpayload.endswith('\n'):
+                endsep = u'\n'
+            payload = uheader + frontsep + oldpayload + endsep + ufooter
+            if lcset == 'us-ascii':
+                newcset = mcset
+            else:
+                newcset = lcset
+            msg.set_payload(payload.encode(newcset), newcset)
+            wrap = 0
+        except:
+            pass
     elif msg.get_type() == 'multipart/mixed':
         # The next easiest thing to do is just prepend the header and
append
         # the footer as additional subparts




More information about the Mailman-Users mailing list