[Mailman-Developers] Serious Archiving problem in 2.1.7

Mark Sapiro msapiro at value.net
Thu Jan 5 04:02:09 CET 2006


Tokio Kikuchi wrote:
>
>At my first glance, it will only work for english lists in which the
>replace parameter _(' at ') is the same both in unicode and ascii.
>
>I'll try to test and generate i18n patch today.


I see the point. Unfortunately I only tested English and French and in
French, _(' at ') translates to ' at '. Here is my suggestion for a
revised patch (tested with en, es, fr and ja - I can't read the
Japanese, but it 'looks' OK):

--- f:/Mailman/mailman-2.1.7/Mailman/Archiver/HyperArch.py     
2005-12-30 10:50:07.000000000 -0800
+++ f:/test-mailman/Mailman/Archiver/HyperArch.py       2006-01-04
18:21:50.750000000 -0800
@@ -569,16 +569,21 @@
         if d['_message_id']:
             headers.append('Message-ID: %(_message_id)s')
         body = EMPTYSTRING.join(self.body)
-        if isinstance(body, types.UnicodeType):
-            body = body.encode(Utils.GetCharSet(self._lang), 'replace')
+        # MAS: Coerce the body to Unicode and replace any invalid
characters.
+        langcset = Utils.GetCharSet(self._lang)
+        if not isinstance(body, types.UnicodeType):
+            body = body.decode(langcset, 'replace')
         if mm_cfg.ARCHIVER_OBSCURES_EMAILADDRS:
             otrans = i18n.get_translation()
             try:
                 i18n.set_language(self._lang)
                 body = re.sub(r'([-+,.\w]+)@([-+.\w]+)',
-                              '\g<1>' + _(' at ') + '\g<2>', body)
+                              '\g<1>' + unicode(_(' at '), langcset)
+                              + '\g<2>', body)
             finally:
                 i18n.set_translation(otrans)
+        # MAS: Return body to character set of article.
+        body = body.encode(langcset, 'replace')
         return NL.join(headers) % d + '\n\n' + body + '\n'

     def _set_date(self, message):

-- 
Mark Sapiro <msapiro at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Developers mailing list