aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Mailman/Bouncers/Yahoo.py35
-rwxr-xr-x[-rw-r--r--]NEWS1
-rw-r--r--tests/bounces/yahoo_11.txt16
-rwxr-xr-xtests/test_bounces.py1
4 files changed, 43 insertions, 10 deletions
diff --git a/Mailman/Bouncers/Yahoo.py b/Mailman/Bouncers/Yahoo.py
index b3edf4fa..47fedce2 100644
--- a/Mailman/Bouncers/Yahoo.py
+++ b/Mailman/Bouncers/Yahoo.py
@@ -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 re
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 @@ def process(msg):
# 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
diff --git a/NEWS b/NEWS
index 00b5c10c..1abf3ada 100644..100755
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,7 @@ Here is a history of user visible changes to Mailman.
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)
diff --git a/tests/bounces/yahoo_11.txt b/tests/bounces/yahoo_11.txt
new file mode 100644
index 00000000..6e9692a6
--- /dev/null
+++ b/tests/bounces/yahoo_11.txt
@@ -0,0 +1,16 @@
+From: MAILER-DAEMON@yahoo.com
+To: user@bellsouth.net
+Date: Wed, 20 Feb 2013 15:50:26 -0000
+Subject: Failure Notice
+
+Sorry, we were unable to deliver your message to the following address.
+
+<bad_user@aol.com>:
+Remote host said: 550 5.1.1 <bad_user@aol.com>: 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.
+
+<bogus@dont.find.me.invalid>:
+
diff --git a/tests/test_bounces.py b/tests/test_bounces.py
index 6bf51570..bb20578c 100755
--- a/tests/test_bounces.py
+++ b/tests/test_bounces.py
@@ -168,6 +168,7 @@ class BounceTest(unittest.TestCase):
('Yahoo', 'yahoo_10.txt', ['jajcchoo@yahoo.com',
'lyons94706@yahoo.com',
'turtle4jne@yahoo.com']),
+ ('Yahoo', 'yahoo_11.txt', ['bad_user@aol.com']),
# sina.com appears to use their own weird SINAEMAIL MTA
('Sina', 'sina_01.txt', ['boboman76@sina.com', 'alan_t18@sina.com']),
('AOL', 'aol_01.txt', ['screenname@aol.com']),