summaryrefslogtreecommitdiff
path: root/Mailman/Mailbox.py
diff options
context:
space:
mode:
authorbwarsaw2002-08-29 17:17:33 +0000
committerbwarsaw2002-08-29 17:17:33 +0000
commita554ebe6a034aa4b2f8d66d0f8c48eec427de347 (patch)
tree0143afbe131b19c6cc241db3c96f6ec0da90dab4 /Mailman/Mailbox.py
parent96b2a458409f8445f4978b74b082eea87263d88d (diff)
downloadmailman-a554ebe6a034aa4b2f8d66d0f8c48eec427de347.tar.gz
mailman-a554ebe6a034aa4b2f8d66d0f8c48eec427de347.tar.zst
mailman-a554ebe6a034aa4b2f8d66d0f8c48eec427de347.zip
Diffstat (limited to 'Mailman/Mailbox.py')
-rw-r--r--Mailman/Mailbox.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/Mailman/Mailbox.py b/Mailman/Mailbox.py
index 9fa3189b0..8ab085cca 100644
--- a/Mailman/Mailbox.py
+++ b/Mailman/Mailbox.py
@@ -23,15 +23,24 @@ import mailbox
import email
from email.Generator import Generator
from email.Parser import Parser
+from email.Errors import MessageParseError
from Mailman import mm_cfg
from Mailman.Message import Message
+
+def _safeparser(fp):
+ try:
+ return email.message_from_file(fp, Message)
+ except MessageParseError:
+ # Don't return None since that will stop a mailbox iterator
+ return ''
+
class Mailbox(mailbox.PortableUnixMailbox):
def __init__(self, fp):
- mailbox.PortableUnixMailbox.__init__(self, fp, email.message_from_file)
+ mailbox.PortableUnixMailbox.__init__(self, fp, _safeparser)
# msg should be an rfc822 message or a subclass.
def AppendMessage(self, msg):
@@ -64,8 +73,9 @@ def _archfactory(mailbox):
# a reference to the mailing list. Nested scopes would help here, BTW,
# but we can't rely on them being around (e.g. Python 2.0).
def scrubber(fp, mailbox=mailbox):
- p = Parser(Message)
- msg = p.parse(fp)
+ msg = _safeparser(fp)
+ if msg == '':
+ return msg
return mailbox.scrub(msg)
return scrubber