Blame SOURCES/mailman-bouncer_oom_crash.patch

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