diff options
author | Mark Sapiro <mark@msapiro.net> | 2015-03-02 13:50:24 -0800 |
---|---|---|
committer | Mark Sapiro <mark@msapiro.net> | 2015-03-02 13:50:24 -0800 |
commit | cc87ff27d108c9991f9ad93d682b06a40e7127bf (patch) | |
tree | 87d9aba39bc0533f0a343bfaa5ff62cb58b6d8a1 /Mailman/Handlers | |
parent | a542b45f13b6da18a63927f3324faa6b3ffefe71 (diff) | |
download | mailman2-cc87ff27d108c9991f9ad93d682b06a40e7127bf.tar.gz mailman2-cc87ff27d108c9991f9ad93d682b06a40e7127bf.tar.xz mailman2-cc87ff27d108c9991f9ad93d682b06a40e7127bf.zip |
A LookupError in SpamDetect on a message with RFC 2047 encoded headers
in an unknown character set is fixed.
Diffstat (limited to 'Mailman/Handlers')
-rw-r--r-- | Mailman/Handlers/SpamDetect.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Mailman/Handlers/SpamDetect.py b/Mailman/Handlers/SpamDetect.py index 119c5beb..d85cc6a6 100644 --- a/Mailman/Handlers/SpamDetect.py +++ b/Mailman/Handlers/SpamDetect.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2013 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2015 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -77,7 +77,15 @@ def getDecodedHeaders(msg, cset='utf-8'): for frag, cs in v: if not cs: cs = 'us-ascii' - uvalue += unicode(frag, cs, 'replace') + try: + uvalue += unicode(frag, cs, 'replace') + except LookupError: + # The encoding charset is unknown. At this point, frag + # has been QP or base64 decoded into a byte string whose + # charset we don't know how to handle. We will try to + # unicode it as iso-8859-1 which may result in a garbled + # mess, but we have to do something. + uvalue += unicode(frag, 'iso-8859-1', 'replace') headers += '%s: %s\n' % (h, uvalue.encode(cset, 'replace')) return headers |