summaryrefslogtreecommitdiff
path: root/Mailman/Queue/CommandRunner.py
diff options
context:
space:
mode:
Diffstat (limited to 'Mailman/Queue/CommandRunner.py')
-rw-r--r--Mailman/Queue/CommandRunner.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/Mailman/Queue/CommandRunner.py b/Mailman/Queue/CommandRunner.py
index 8967e2f65..e08d02eb5 100644
--- a/Mailman/Queue/CommandRunner.py
+++ b/Mailman/Queue/CommandRunner.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2004 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
@@ -40,9 +40,10 @@ from Mailman.Logging.Syslog import syslog
from Mailman import LockFile
from email.Header import decode_header, make_header, Header
+from email.Errors import HeaderParseError
+from email.Iterators import typed_subpart_iterator
from email.MIMEText import MIMEText
from email.MIMEMessage import MIMEMessage
-from email.Iterators import typed_subpart_iterator
NL = '\n'
@@ -72,9 +73,15 @@ class Results:
# Extract the subject header and do RFC 2047 decoding. Note that
# Python 2.1's unicode() builtin doesn't call obj.__unicode__().
subj = msg.get('subject', '')
- subj = make_header(decode_header(subj)).__unicode__()
- # Always process the Subject: header first
- self.commands.append(subj)
+ try:
+ subj = make_header(decode_header(subj)).__unicode__()
+ # TK: Currently we don't allow 8bit or multibyte in mail command.
+ subj = subj.encode('us-ascii')
+ # Always process the Subject: header first
+ self.commands.append(subj)
+ except (HeaderParseError, UnicodeError, LookupError):
+ # We couldn't parse it so ignore the Subject header
+ pass
# Find the first text/plain part
part = None
for part in typed_subpart_iterator(msg, 'text', 'plain'):
@@ -163,7 +170,7 @@ To obtain instructions, send a message containing just the word "help".
resp.append(_('\n- Done.\n\n'))
# Encode any unicode strings into the list charset, so we don't try to
# join unicode strings and invalid ASCII.
- charset = Utils.GetCharSet(self.mlist.preferred_language)
+ charset = Utils.GetCharSet(self.msgdata['lang'])
encoded_resp = []
for item in resp:
if isinstance(item, UnicodeType):
@@ -179,13 +186,13 @@ To obtain instructions, send a message containing just the word "help".
# BAW: We wait until now to make this decision since our sender may
# not be self.msg.get_sender(), but I'm not sure this is right.
recip = self.returnaddr or self.msg.get_sender()
- if not self.mlist.autorespondToSender(recip):
+ if not self.mlist.autorespondToSender(recip, self.msgdata['lang']):
return
msg = Message.UserNotification(
recip,
self.mlist.GetBouncesEmail(),
_('The results of your email commands'),
- lang=self.mlist.preferred_language)
+ lang=self.msgdata['lang'])
msg.set_type('multipart/mixed')
msg.attach(results)
orig = MIMEMessage(self.msg)