From d38cdadc2e2ccdeef4cd8cc3e30d41418ae11c83 Mon Sep 17 00:00:00 2001 From: tkikuchi <> Date: Sat, 11 Dec 2004 00:27:04 +0000 Subject: Fix for unknown/malicious charset value. --- Mailman/Handlers/ToDigest.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Mailman/Handlers') diff --git a/Mailman/Handlers/ToDigest.py b/Mailman/Handlers/ToDigest.py index 9051e846..e41fa244 100644 --- a/Mailman/Handlers/ToDigest.py +++ b/Mailman/Handlers/ToDigest.py @@ -141,7 +141,7 @@ def send_i18n_digests(mlist, mboxfp): # Prepare common information (first lang/charset) lang = mlist.preferred_language lcset = Utils.GetCharSet(lang) - lcset_out = Charset(lcset).output_charset + lcset_out = Charset(lcset).output_charset or lcset # Common Information (contd) realname = mlist.real_name volume = mlist.volume @@ -321,8 +321,14 @@ def send_i18n_digests(mlist, mboxfp): or msg.as_string().split('\n\n',1)[1] mcset = msg.get_content_charset('') if mcset and mcset <> lcset and mcset <> lcset_out: - payload = unicode(payload, mcset, 'replace' - ).encode(lcset, 'replace') + try: + payload = unicode(payload, mcset, 'replace' + ).encode(lcset, 'replace') + except LookupError: + # TK: Message has something unknown charset. + # _out means charset in 'outer world'. + payload = unicode(payload, lcset_out, 'replace' + ).encode(lcset, 'replace') print >> plainmsg, payload if not payload.endswith('\n'): print >> plainmsg -- cgit v1.2.3