summaryrefslogtreecommitdiff
path: root/Mailman
diff options
context:
space:
mode:
authorbwarsaw2001-12-07 04:08:56 +0000
committerbwarsaw2001-12-07 04:08:56 +0000
commit7aef45047389a58788459ca0b5575ab2fe0383a7 (patch)
tree166e718fb3a8314875ceff47db34caac35e1f7d6 /Mailman
parentcf4bada23c549ef0cb3804405156baa0f371e7ed (diff)
downloadmailman-7aef45047389a58788459ca0b5575ab2fe0383a7.tar.gz
mailman-7aef45047389a58788459ca0b5575ab2fe0383a7.tar.zst
mailman-7aef45047389a58788459ca0b5575ab2fe0383a7.zip
__verpbounce(): Dan Mick points out that we were still hardcoding the
VERP decoding. Use mm_cfg.VERP_REGEXP instead.
Diffstat (limited to 'Mailman')
-rw-r--r--Mailman/Queue/BounceRunner.py53
1 files changed, 26 insertions, 27 deletions
diff --git a/Mailman/Queue/BounceRunner.py b/Mailman/Queue/BounceRunner.py
index d6445e1c7..bd4f9bdf3 100644
--- a/Mailman/Queue/BounceRunner.py
+++ b/Mailman/Queue/BounceRunner.py
@@ -16,6 +16,9 @@
"""Bounce queue runner."""
+import re
+from email.Utils import parseaddr
+
from Mailman import mm_cfg
from Mailman import Utils
from Mailman import MailList
@@ -90,33 +93,29 @@ class BounceRunner(Runner):
def __verpbounce(self, mlist, msg):
bmailbox, bdomain = Utils.ParseEmail(mlist.getListAddress('bounces'))
- if msg.get('to', '').startswith(bmailbox):
- i = len(bmailbox)
- mailbox, domain = Utils.ParseEmail(msg['to'])
- encaddr = mailbox[i+1:]
- # Find the right-most = sign. BAW: hardcoded. :(
- i = encaddr.rfind('=')
- if i > 0:
- addr = encaddr[:i] + '@' + encaddr[i+1:]
- # Now, if this message has come to the site list, then
- # search not only it, but all the mailing lists on the
- # system, registering a bounce with each for this address.
- if mlist.internal_name() == mm_cfg.MAILMAN_SITE_LIST:
- found = 0
- for listname in Utils.list_names():
- xlist = MailList.MailList(listname, lock=0)
- if xlist.isMember(addr):
- xlist.Lock()
- try:
- xlist.RegisterBounce(addr, msg)
- found = 1
- xlist.Save()
- finally:
- xlist.Unlock()
- return found
- elif mlist.isMember(addr):
- mlist.RegisterBounce(addr, msg)
- return 1
+ to = msg.get('to', '')
+ mo = re.search(mm_cfg.VERP_REGEXP, parseaddr(to)[1])
+ if to.startswith(bmailbox) and mo:
+ addr = '%s@%s' % mo.group('mailbox', 'host')
+ # Now, if this message has come to the site list, then search not
+ # only it, but all the mailing lists on the system, registering a
+ # bounce with each for this address.
+ if mlist.internal_name() == mm_cfg.MAILMAN_SITE_LIST:
+ found = 0
+ for listname in Utils.list_names():
+ xlist = MailList.MailList(listname, lock=0)
+ if xlist.isMember(addr):
+ xlist.Lock()
+ try:
+ xlist.RegisterBounce(addr, msg)
+ found = 1
+ xlist.Save()
+ finally:
+ xlist.Unlock()
+ return found
+ elif mlist.isMember(addr):
+ mlist.RegisterBounce(addr, msg)
+ return 1
return 0
def __scanbounce(self, mlist, msg):