From e6677adc3deba62d4a05c0ff4ce891ec09b9a925 Mon Sep 17 00:00:00 2001 From: tkikuchi <> Date: Mon, 9 Jan 2006 07:33:36 +0000 Subject: Text file '@' obfuscation bug (unicode) fix. Thanks Mark. --- Mailman/Archiver/HyperArch.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py index 732ab10e..bd3802bc 100644 --- a/Mailman/Archiver/HyperArch.py +++ b/Mailman/Archiver/HyperArch.py @@ -569,16 +569,21 @@ class Article(pipermail.Article): 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') + cset = Utils.GetCharSet(self._lang) + # Coerce the body to Unicode and replace any invalid characters. + if not isinstance(body, types.UnicodeType): + body = unicode(body, cset, 'replace') if mm_cfg.ARCHIVER_OBSCURES_EMAILADDRS: otrans = i18n.get_translation() try: + atmark = unicode(_(' at '), cset) i18n.set_language(self._lang) body = re.sub(r'([-+,.\w]+)@([-+.\w]+)', - '\g<1>' + _(' at ') + '\g<2>', body) + '\g<1>' + atmark + '\g<2>', body) finally: i18n.set_translation(otrans) + # Return body to character set of article. + body = body.encode(cset, 'replace') return NL.join(headers) % d + '\n\n' + body + '\n' def _set_date(self, message): -- cgit v1.2.3