------------------------------------------------------------
revno: 1241
committer: Mark Sapiro <[email protected]>
branch nick: 2.2
timestamp: Wed 2013-03-20 18:37:07 -0700
message:
Added recognition for another Yahoo bounce format. LP: #1157961
added:
tests/bounces/yahoo_11.txt
modified:
Mailman/Bouncers/Yahoo.py
NEWS
tests/test_bounces.py
--
lp:mailman/2.2
https://code.launchpad.net/~mailman-coders/mailman/2.2
Your team Mailman Checkins is subscribed to branch lp:mailman/2.2.
To unsubscribe from this branch go to
https://code.launchpad.net/~mailman-coders/mailman/2.2/+edit-subscription
=== modified file 'Mailman/Bouncers/Yahoo.py'
--- Mailman/Bouncers/Yahoo.py 2005-08-27 01:40:17 +0000
+++ Mailman/Bouncers/Yahoo.py 2013-03-21 01:37:07 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 1998,1999,2000,2001,2002 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
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Yahoo! has its own weird format for bounces."""
@@ -20,9 +21,15 @@
import email
from email.Utils import parseaddr
-tcre = re.compile(r'message\s+from\s+yahoo\.\S+', re.IGNORECASE)
+tcre = (re.compile(r'message\s+from\s+yahoo\.\S+', re.IGNORECASE),
+ re.compile(r'Sorry, we were unable to deliver your message to '
+ r'the following address(\(es\))?\.',
+ re.IGNORECASE),
+ )
acre = re.compile(r'<(?P<addr>[^>]*)>:')
-ecre = re.compile(r'--- Original message follows')
+ecre = (re.compile(r'--- Original message follows'),
+ re.compile(r'--- Below this line is a copy of the message'),
+ )
@@ -36,18 +43,26 @@
# simple state machine
# 0 == nothing seen
# 1 == tag line seen
+ # 2 == end line seen
state = 0
for line in email.Iterators.body_line_iterator(msg):
line = line.strip()
- if state == 0 and tcre.match(line):
- state = 1
+ if state == 0:
+ for cre in tcre:
+ if cre.match(line):
+ state = 1
+ break
elif state == 1:
mo = acre.match(line)
if mo:
addrs.append(mo.group('addr'))
continue
- mo = ecre.match(line)
- if mo:
- # we're at the end of the error response
- break
+ for cre in ecre:
+ mo = cre.match(line)
+ if mo:
+ # we're at the end of the error response
+ state = 2
+ break
+ elif state == 2:
+ break
return addrs
=== modified file 'NEWS'
--- NEWS 2013-03-11 03:29:45 +0000
+++ NEWS 2013-03-21 01:37:07 +0000
@@ -96,6 +96,7 @@
Bug Fixes and other patches
+ - Added recognition for another Yahoo bounce format. LP: #1157961
- Changed configure's method for getting Python's include directory from
distutils.sysconfig.get_config_var('CONFINCLUDEPY') to
distutils.sysconfig.get_python_inc(). (LP: 1098162)
=== added file 'tests/bounces/yahoo_11.txt'
--- tests/bounces/yahoo_11.txt 1970-01-01 00:00:00 +0000
+++ tests/bounces/yahoo_11.txt 2013-03-21 01:37:07 +0000
@@ -0,0 +1,16 @@
+From: [email protected]
+To: [email protected]
+Date: Wed, 20 Feb 2013 15:50:26 -0000
+Subject: Failure Notice
+
+Sorry, we were unable to deliver your message to the following address.
+
+<[email protected]>:
+Remote host said: 550 5.1.1 <[email protected]>: Recipient address rejected: aol.com [RCPT_TO]
+
+--- Below this line is a copy of the message.
+
+The following should not be found as we should have stopped looking.
+
+<[email protected]>:
+
=== modified file 'tests/test_bounces.py'
--- tests/test_bounces.py 2011-12-25 17:27:31 +0000
+++ tests/test_bounces.py 2013-03-21 01:37:07 +0000
@@ -168,6 +168,7 @@
('Yahoo', 'yahoo_10.txt', ['[email protected]',
'[email protected]',
'[email protected]']),
+ ('Yahoo', 'yahoo_11.txt', ['[email protected]']),
# sina.com appears to use their own weird SINAEMAIL MTA
('Sina', 'sina_01.txt', ['[email protected]', '[email protected]']),
('AOL', 'aol_01.txt', ['[email protected]']),
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org