e873e9
--- Mailman/Bouncers/SimpleMatch.py	2018-06-17 23:47:34 +0000
e873e9
+++ Mailman/Bouncers/SimpleMatch.py	2020-01-17 00:03:34 +0000
e873e9
@@ -25,6 +25,9 @@
e873e9
 def _c(pattern):
e873e9
     return re.compile(pattern, re.IGNORECASE)
e873e9
 
e873e9
+# Pattern to match any valid email address and not much more.
e873e9
+VALID = _c(r'[\x21-\x3d\x3f\x41-\x7e]+@[a-z0-9._]+')
e873e9
+
e873e9
 # This is a list of tuples of the form
e873e9
 #
e873e9
 #     (start cre, end cre, address cre)
e873e9
@@ -227,4 +230,4 @@
e873e9
                     break
e873e9
         if addrs:
e873e9
             break
e873e9
-    return addrs.keys()
e873e9
+    return [x for x in addrs.keys() if VALID.match(x)]
e873e9
e873e9
=== modified file 'Mailman/Bouncers/SimpleWarning.py'
e873e9
--- Mailman/Bouncers/SimpleWarning.py	2018-06-17 23:47:34 +0000
e873e9
+++ Mailman/Bouncers/SimpleWarning.py	2020-01-17 00:03:34 +0000
e873e9
@@ -17,9 +17,10 @@
e873e9
 
e873e9
 """Recognizes simple heuristically delimited warnings."""
e873e9
 
e873e9
+import email
e873e9
+
e873e9
 from Mailman.Bouncers.BouncerAPI import Stop
e873e9
 from Mailman.Bouncers.SimpleMatch import _c
e873e9
-from Mailman.Bouncers.SimpleMatch import process as _process
e873e9
 
e873e9
 
e873e9
 
e873e9
@@ -67,8 +68,25 @@
e873e9
 
e873e9
 
e873e9
 def process(msg):
e873e9
-    if _process(msg, patterns):
e873e9
-        # It's a recognized warning so stop now
e873e9
-        return Stop
e873e9
-    else:
e873e9
-        return []
e873e9
+    # We used to just import process from SimpleMatch, but with the change in
e873e9
+    # SimpleMatch to return only vaild addresses, that doesn't work any more.
e873e9
+    # So, we copy most of the process from SimpleMatch here.
e873e9
+    addrs = {}
e873e9
+    for scre, ecre, acre in patterns:
e873e9
+        state = 0
e873e9
+        for line in email.Iterators.body_line_iterator(msg, decode=True):
e873e9
+            if state == 0:
e873e9
+                if scre.search(line):
e873e9
+                    state = 1
e873e9
+            if state == 1:
e873e9
+                mo = acre.search(line)
e873e9
+                if mo:
e873e9
+                    addr = mo.group('addr')
e873e9
+                    if addr:
e873e9
+                        addrs[addr.strip('<>')] = 1
e873e9
+                elif ecre.search(line):
e873e9
+                    break
e873e9
+        if addrs:
e873e9
+            # It's a recognized warning so stop now
e873e9
+            return Stop
e873e9
+    return []
e873e9
e873e9
--- Mailman/Bouncers/SimpleMatch.py	2020-01-17 00:03:34 +0000
e873e9
+++ Mailman/Bouncers/SimpleMatch.py	2020-01-17 03:25:09 +0000
e873e9
@@ -26,7 +26,7 @@
e873e9
     return re.compile(pattern, re.IGNORECASE)
e873e9
 
e873e9
 # Pattern to match any valid email address and not much more.
e873e9
-VALID = _c(r'[\x21-\x3d\x3f\x41-\x7e]+@[a-z0-9._]+')
e873e9
+VALID = _c(r'^[\x21-\x3d\x3f\x41-\x7e]+@[a-z0-9._]+$')
e873e9
 
e873e9
 # This is a list of tuples of the form
e873e9
 #
e873e9