diff options
| author | klm | 1998-04-23 15:47:21 +0000 |
|---|---|---|
| committer | klm | 1998-04-23 15:47:21 +0000 |
| commit | 22e2ef1261977f24404a0fb959ce5c433e057bab (patch) | |
| tree | ee6341fa6bef344708d7ec84f0698397cec57cdf | |
| parent | 16df979b80a450f93106bfbc02cd9f87e2d33436 (diff) | |
| download | mailman-22e2ef1261977f24404a0fb959ce5c433e057bab.tar.gz mailman-22e2ef1261977f24404a0fb959ce5c433e057bab.tar.zst mailman-22e2ef1261977f24404a0fb959ce5c433e057bab.zip | |
These changes should reduce, if not eliminate, the duplicate handling
of bounce violators, and also reduce if not eliminate the number of
invalid address targets.
.ScanMessage(): Instead of handling each email addr as it's encountered,
collect together all the candidates and go through them all at the
end, rejecting duplicates. This way, candidates found repeatedly in
different cases won't be processed multiple times.
.ExtractBouncingAddr(): Prevent a commonly recurrent aberrant address
gleaning, eg: "<klm@python.org>..." - many error notice lines have
that elipsis after the address, and it was not being adequately
filtered. Now it is.
| -rw-r--r-- | Mailman/Bouncer.py | 27 | ||||
| -rw-r--r-- | modules/mm_bouncer.py | 27 |
2 files changed, 26 insertions, 28 deletions
diff --git a/Mailman/Bouncer.py b/Mailman/Bouncer.py index 7063a1bc6..7aea2d322 100644 --- a/Mailman/Bouncer.py +++ b/Mailman/Bouncer.py @@ -1,6 +1,6 @@ "Handle delivery bounce messages, doing filtering when list is set for it." -__version__ = "$Revision: 418 $" +__version__ = "$Revision: 463 $" # It's possible to get the mail-list senders address (list-admin) in the # bounce list. You probably don't want to have list mail sent to that @@ -16,9 +16,8 @@ class Bouncer: # Not configurable... self.bounce_info = {} - - self.bounce_processing = mm_cfg.DEFAULT_BOUNCE_PROCESSING # Configurable... + self.bounce_processing = mm_cfg.DEFAULT_BOUNCE_PROCESSING self.minimum_removal_date = mm_cfg.DEFAULT_MINIMUM_REMOVAL_DATE self.minimum_post_count_before_bounce_action = \ mm_cfg.DEFAULT_MINIMUM_POST_COUNT_BEFORE_BOUNCE_ACTION @@ -210,6 +209,7 @@ class Bouncer: def ScanMessage(self, msg): ## realname, who_from = msg.getaddr('from') ## who_info = string.lower(who_from) + candidates = [] who_info = string.lower(msg.GetSender()) at_index = string.find(who_info, '@') who_from = who_info[:at_index] @@ -266,18 +266,12 @@ class Bouncer: message_groked = 0 - did = [] for line in string.split(relevant_text, '\n'): for pattern, action in simple_bounce_pats: if pattern.match(line) <> -1: email = self.ExtractBouncingAddr(line) if action == REMOVE: - emails = string.split(email,',') - for email_addr in emails: - if email_addr not in did: - self.HandleBouncingAddress( - string.strip(email_addr)) - did.append(email_addr) + candidates = candidates + string.split(email,',') message_groked = 1 continue elif action == BOUNCE: @@ -301,26 +295,31 @@ class Bouncer: or messy_pattern_4.match(line) <> -1 or messy_pattern_5.match(line) <> -1): username = string.split(line)[1] - self.HandleBouncingAddress('%s@%s' % (username, remote_host)) + candidates.append('%s@%s' % (username, remote_host)) message_groked = 1 continue if messy_pattern_6.match(line) <> -1: username = string.split(string.strip(line))[0][:-1] - self.HandleBouncingAddress('%s@%s' % (username, remote_host)) + candidates.append('%s@%s' % (username, remote_host)) message_groked = 1 continue if messy_pattern_7.match(line) <> -1: username = string.split(string.strip(line))[0] - self.HandleBouncingAddress('%s@%s' % (username, remote_host)) + candidates.append('%s@%s' % (username, remote_host)) message_groked = 1 continue + did = [] + for i in candidates: + if i not in did: + self.HandleBouncingAddress(i) + did.append(i) return message_groked def ExtractBouncingAddr(self, line): # First try with angles: email = regsub.splitx(line, '[^ \t@<>]+@[^ \t@<>]+\.[^ \t<>.]+')[1] if email[0] == '<': - return email[1:-1] + return regsub.splitx(email[1:], ">")[0] else: return email diff --git a/modules/mm_bouncer.py b/modules/mm_bouncer.py index 7063a1bc6..7aea2d322 100644 --- a/modules/mm_bouncer.py +++ b/modules/mm_bouncer.py @@ -1,6 +1,6 @@ "Handle delivery bounce messages, doing filtering when list is set for it." -__version__ = "$Revision: 418 $" +__version__ = "$Revision: 463 $" # It's possible to get the mail-list senders address (list-admin) in the # bounce list. You probably don't want to have list mail sent to that @@ -16,9 +16,8 @@ class Bouncer: # Not configurable... self.bounce_info = {} - - self.bounce_processing = mm_cfg.DEFAULT_BOUNCE_PROCESSING # Configurable... + self.bounce_processing = mm_cfg.DEFAULT_BOUNCE_PROCESSING self.minimum_removal_date = mm_cfg.DEFAULT_MINIMUM_REMOVAL_DATE self.minimum_post_count_before_bounce_action = \ mm_cfg.DEFAULT_MINIMUM_POST_COUNT_BEFORE_BOUNCE_ACTION @@ -210,6 +209,7 @@ class Bouncer: def ScanMessage(self, msg): ## realname, who_from = msg.getaddr('from') ## who_info = string.lower(who_from) + candidates = [] who_info = string.lower(msg.GetSender()) at_index = string.find(who_info, '@') who_from = who_info[:at_index] @@ -266,18 +266,12 @@ class Bouncer: message_groked = 0 - did = [] for line in string.split(relevant_text, '\n'): for pattern, action in simple_bounce_pats: if pattern.match(line) <> -1: email = self.ExtractBouncingAddr(line) if action == REMOVE: - emails = string.split(email,',') - for email_addr in emails: - if email_addr not in did: - self.HandleBouncingAddress( - string.strip(email_addr)) - did.append(email_addr) + candidates = candidates + string.split(email,',') message_groked = 1 continue elif action == BOUNCE: @@ -301,26 +295,31 @@ class Bouncer: or messy_pattern_4.match(line) <> -1 or messy_pattern_5.match(line) <> -1): username = string.split(line)[1] - self.HandleBouncingAddress('%s@%s' % (username, remote_host)) + candidates.append('%s@%s' % (username, remote_host)) message_groked = 1 continue if messy_pattern_6.match(line) <> -1: username = string.split(string.strip(line))[0][:-1] - self.HandleBouncingAddress('%s@%s' % (username, remote_host)) + candidates.append('%s@%s' % (username, remote_host)) message_groked = 1 continue if messy_pattern_7.match(line) <> -1: username = string.split(string.strip(line))[0] - self.HandleBouncingAddress('%s@%s' % (username, remote_host)) + candidates.append('%s@%s' % (username, remote_host)) message_groked = 1 continue + did = [] + for i in candidates: + if i not in did: + self.HandleBouncingAddress(i) + did.append(i) return message_groked def ExtractBouncingAddr(self, line): # First try with angles: email = regsub.splitx(line, '[^ \t@<>]+@[^ \t@<>]+\.[^ \t<>.]+')[1] if email[0] == '<': - return email[1:-1] + return regsub.splitx(email[1:], ">")[0] else: return email |
