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