diff options
| author | bwarsaw | 2001-08-29 05:55:49 +0000 |
|---|---|---|
| committer | bwarsaw | 2001-08-29 05:55:49 +0000 |
| commit | 0242e616245d1b0d92057b09e5dbaba47116270b (patch) | |
| tree | 0d37772797832e6c34e4dc1c4659e693f1847851 /Mailman/Handlers/SpamDetect.py | |
| parent | 90d62bec18278a7e83fe5571523c46b20ce2fc95 (diff) | |
| download | mailman-0242e616245d1b0d92057b09e5dbaba47116270b.tar.gz mailman-0242e616245d1b0d92057b09e5dbaba47116270b.tar.zst mailman-0242e616245d1b0d92057b09e5dbaba47116270b.zip | |
Move KNOWN_SPAMMERS out of this file and into Defaults.py.in so it can
be properly configured in mm_cfg.py.
process(): Don't support the header == None semantics (it was broken
anyway). We may have to add this back later.
Diffstat (limited to 'Mailman/Handlers/SpamDetect.py')
| -rw-r--r-- | Mailman/Handlers/SpamDetect.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/Mailman/Handlers/SpamDetect.py b/Mailman/Handlers/SpamDetect.py index b4f77a98d..59579da7a 100644 --- a/Mailman/Handlers/SpamDetect.py +++ b/Mailman/Handlers/SpamDetect.py @@ -25,34 +25,26 @@ TBD: This needs to be made more configurable and robust. """ import re + +from Mailman import mm_cfg from Mailman import Errors + + class SpamDetected(Errors.DiscardMessage): """The message contains known spam""" -# This variable contains a list of 2-tuple of the format (header, regex) which -# this module uses to match against the current message. If the regex matches -# the given header in the current message, then it is flagged as spam. header -# can be None to indicate regex search of the body of the message. Note that -# the more searching done, the slower this whole process gets. - -KNOWN_SPAMMERS = [] - - def process(mlist, msg, msgdata): if msgdata.get('approved'): return - for header, regex in KNOWN_SPAMMERS: + for header, regex in mm_cfg.KNOWN_SPAMMERS: cre = re.compile(regex, re.IGNORECASE) - if header is None: - text = msg.body - else: - text = msg.get(header) - if not text: - continue - mo = cre.search(text) + value = msg[header] + if not value: + continue + mo = cre.search(value) if mo: # we've detected spam, so throw the message away raise SpamDetected |
