aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/Handlers/ToDigest.py
diff options
context:
space:
mode:
authortkikuchi <>2004-12-11 00:27:04 +0000
committertkikuchi <>2004-12-11 00:27:04 +0000
commitd38cdadc2e2ccdeef4cd8cc3e30d41418ae11c83 (patch)
treeea960ca8cba2b18106a1cbfa0db6e39f5c7fdb74 /Mailman/Handlers/ToDigest.py
parentbbfc566fc296a9235378b8739c820dfff7a3f67c (diff)
downloadmailman2-d38cdadc2e2ccdeef4cd8cc3e30d41418ae11c83.tar.gz
mailman2-d38cdadc2e2ccdeef4cd8cc3e30d41418ae11c83.tar.xz
mailman2-d38cdadc2e2ccdeef4cd8cc3e30d41418ae11c83.zip
Fix for unknown/malicious charset value.
Diffstat (limited to '')
-rw-r--r--Mailman/Handlers/ToDigest.py12
1 files changed, 9 insertions, 3 deletions
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