From a00756ae6f62dbef3689726a137eba3014b8f3dc Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Tue, 17 Sep 2002 21:37:26 +0000 Subject: ParseTags(): Python will barf when trying to string-join a sequence if all the strings aren't properly encoded. To make life as easy as possible, make sure that all the items in the split sequence are 8-bit strings, encoded if necessary in the charset of the language given in the argument list. --- Mailman/HTMLFormatter.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Mailman/HTMLFormatter.py') diff --git a/Mailman/HTMLFormatter.py b/Mailman/HTMLFormatter.py index bf291d79a..03818ff4f 100644 --- a/Mailman/HTMLFormatter.py +++ b/Mailman/HTMLFormatter.py @@ -346,13 +346,20 @@ class HTMLFormatter: return '' def ParseTags(self, template, replacements, lang=None): + if lang is None: + charset = 'us-ascii' + else: + charset = Utils.GetCharSet(lang) text = Utils.maketext(template, raw=1, lang=lang, mlist=self) parts = re.split('(]*>)', text) i = 1 while i < len(parts): tag = parts[i].lower() if replacements.has_key(tag): - parts[i] = replacements[tag] + repl = replacements[tag] + if isinstance(repl, type(u'')): + repl = repl.encode(charset, 'replace') + parts[i] = repl else: parts[i] = '' i = i + 2 -- cgit v1.2.3-70-g09d2