summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2001-07-13 17:00:34 +0000
committerbwarsaw2001-07-13 17:00:34 +0000
commit6c47bb5b932850784f99c8ed4b0627dd9b22d276 (patch)
tree1657447433a1500e7abb86ead3feeb65ffc2820b
parenta41aa936b93b2187257d5096ebfa4b2eb13b9603 (diff)
downloadmailman-6c47bb5b932850784f99c8ed4b0627dd9b22d276.tar.gz
mailman-6c47bb5b932850784f99c8ed4b0627dd9b22d276.tar.zst
mailman-6c47bb5b932850784f99c8ed4b0627dd9b22d276.zip
process(): Be much more careful about bogus source strings for the
dictionary interpolation. Since they're coming from the great unwashed masses, the autoresponse texts could have bogus %()s bits in them, and using a SafeDict doesn't guard against all kinds of exceptions. So, if any exception is caught during interpolation, log it, and use the raw autoresponse text in the email. Also, because we're not using the buggy rfc822.py module anymore, we don't need to special case the situation when the first line of the autoresponse text has a colon in it.
-rw-r--r--Mailman/Handlers/Replybot.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/Mailman/Handlers/Replybot.py b/Mailman/Handlers/Replybot.py
index 4adc77a67..7e3a3be4b 100644
--- a/Mailman/Handlers/Replybot.py
+++ b/Mailman/Handlers/Replybot.py
@@ -23,8 +23,7 @@ from Mailman import Utils
from Mailman import Message
from Mailman.i18n import _
from Mailman.SafeDict import SafeDict
-
-NL = '\n'
+from Mailman.Logging.Syslog import syslog
@@ -73,21 +72,23 @@ def process(mlist, msg, msgdata):
'adminemail' : mlist.GetAdminEmail(),
'owneremail' : mlist.GetOwnerEmail(),
})
+ # Just because we're using a SafeDict doesn't mean we can't get all sorts
+ # of other exceptions from the string interpolation. Let's be ultra
+ # conservative here.
if toadmin:
- text = mlist.autoresponse_admin_text % d
+ rtext = mlist.autoresponse_admin_text
elif torequest:
- text = mlist.autoresponse_request_text % d
+ rtext = mlist.autoresponse_request_text
else:
- text = mlist.autoresponse_postings_text % d
- #
- # If the autoresponse text contains a colon in its first line, the headers
- # and body will be mixed up. The fix is to include a blank delimiting
- # line at the front of the wrapped text.
+ rtext = mlist.autoresponse_postings_text
+ try:
+ text = rtext % d
+ except Exception, e:
+ syslog('error', 'Bad autoreply text for list: %s\n%s',
+ mlist.internal_name(), rtext)
+ text = rtext
+ # Wrap the response.
text = Utils.wrap(text)
- lines = text.split('\n')
- if lines[0].find(':') >= 0:
- lines.insert(0, '')
- text = NL.join(lines)
outmsg = Message.UserNotification(sender, mlist.GetAdminEmail(),
subject, text)
outmsg['X-Mailer'] = _('The Mailman Replybot')