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