From 68073e8b93147371bc020afd3b41d5e173574044 Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Mon, 7 Oct 2013 21:57:09 -0700 Subject: - Fixed a crash in SpamDetect.py which caused messages with unparseable RFC 2047 encoded headers to be shunted. (LP: #1235101) --- Mailman/Handlers/SpamDetect.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Mailman') diff --git a/Mailman/Handlers/SpamDetect.py b/Mailman/Handlers/SpamDetect.py index 8d26da03..9e01f623 100644 --- a/Mailman/Handlers/SpamDetect.py +++ b/Mailman/Handlers/SpamDetect.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2013 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 @@ -27,6 +27,7 @@ TBD: This needs to be made more configurable and robust. import re +from email.Errors import HeaderParseError from email.Header import decode_header from Mailman import mm_cfg @@ -68,7 +69,10 @@ def getDecodedHeaders(msg, cset='utf-8'): headers = '' for h, v in msg.items(): uvalue = u'' - v = decode_header(re.sub('\n\s', ' ', v)) + try: + v = decode_header(re.sub('\n\s', ' ', v)) + except HeaderParseError: + v = [(v, 'us-ascii')] for frag, cs in v: if not cs: cs = 'us-ascii' -- cgit v1.2.3