summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2000-06-06 04:07:59 +0000
committerbwarsaw2000-06-06 04:07:59 +0000
commit229cd77566b9c81a154bdbe35e2af5e75e702fba (patch)
treeb9c3a4b2f3c7453fae729a106d55f01ed96a57fb
parent4c0583a23f7410a00a82d0143255c6f98dd30ba9 (diff)
downloadmailman-229cd77566b9c81a154bdbe35e2af5e75e702fba.tar.gz
mailman-229cd77566b9c81a154bdbe35e2af5e75e702fba.tar.zst
mailman-229cd77566b9c81a154bdbe35e2af5e75e702fba.zip
Liberalize the regular expression matching a bit to handle other MTA's
which I suspect are Smail. They all have a very similar format that, if they aren't Smail-based, are close enough for this detector to score.
-rw-r--r--Mailman/Bouncers/Smail.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/Mailman/Bouncers/Smail.py b/Mailman/Bouncers/Smail.py
index 56389a86c..b2e80ee83 100644
--- a/Mailman/Bouncers/Smail.py
+++ b/Mailman/Bouncers/Smail.py
@@ -19,12 +19,10 @@
import string
import re
-introtag = '|------------------------- ' \
- 'Failed addresses follow: ---------------------|'
-endtag = '|------------------------- ' \
- 'Message text follows: ------------------------|'
+scre = re.compile(r'failed addresses follow:', re.IGNORECASE)
+ecre = re.compile(r'message text follows:', re.IGNORECASE)
+acre = re.compile(r'<(?P<addr>[^>]*)>')
-acre = re.compile(r'\s*address:\s*<(?P<addr>[^>]*)>')
def process(msg):
@@ -38,13 +36,15 @@ def process(msg):
line = msg.fp.readline()
if not line:
break
- line = string.strip(line)
- if state == 0 and line == introtag:
- state = 1
- elif state == 2 and line == endtag:
- break
- mo = acre.match(line)
- if mo:
- addrs.append(mo.group('addr'))
- # don't know what we're looking at
+ if state == 0:
+ mo = scre.search(line)
+ if mo:
+ state = 1
+ elif state == 1:
+ mo = ecre.search(line)
+ if mo:
+ break
+ mo = acre.search(line)
+ if mo:
+ addrs.append(mo.group('addr'))
return addrs or None