diff options
| author | klm | 1998-03-08 17:00:21 +0000 |
|---|---|---|
| committer | klm | 1998-03-08 17:00:21 +0000 |
| commit | 2465b4fccbb8ccedfe80b6e04a0e2518e8713667 (patch) | |
| tree | 30c665d42ec84577b30b081f004a4285063ef25d /modules/mm_utils.py | |
| parent | 4abcbbcf31c22094cf23706749a7e8624cde8617 (diff) | |
| download | mailman-2465b4fccbb8ccedfe80b6e04a0e2518e8713667.tar.gz mailman-2465b4fccbb8ccedfe80b6e04a0e2518e8713667.tar.zst mailman-2465b4fccbb8ccedfe80b6e04a0e2518e8713667.zip | |
ObscureEmail(), UnobscureEmail(): new routines for invertably
transforming email addresses so they're not apparent to web spiders,
therefore not scrapable by spammers.
The UnobscureEmail transformation should work like an identity
function on already-unobscured addresses, so it can be used with
impunity.
The routines should be used as functional interface to address
obscuring, so the scheme can be changed transparently to the rest of
the system, just by changing the routines. This should make it easy
to up the ante in the thwarting of spammers, if this catches on.
Diffstat (limited to 'modules/mm_utils.py')
| -rw-r--r-- | modules/mm_utils.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/mm_utils.py b/modules/mm_utils.py index 13f517d09..80f7c55ea 100644 --- a/modules/mm_utils.py +++ b/modules/mm_utils.py @@ -1,4 +1,4 @@ -import string, fcntl, os, random, regsub +import string, fcntl, os, random, regsub, re import mm_cfg # Valid toplevel domains for when we check the validity of an email address. @@ -157,3 +157,22 @@ def QuoteHyperChars(str): arr[i] = '&' i = i + 2 return string.join(arr, '') + +# Just changing these two functions should be enough to control the way +# that email address obscuring is handled. + +def ObscureEmail(addr, for_text=0): + """Make email address unrecognizable to web spiders, but invertable. + + When for_text option is set (not default), make a sentence fragment + instead of a token.""" + if for_text: + return re.sub("@", " at ", addr) + else: + return re.sub("@", "__at__", addr) + +def UnobscureEmail(addr): + """Invert ObscureEmail() conversion.""" + # Contrived to act as an identity operation on already-unobscured + # emails, so routines expecting obscured ones will accept both. + return re.sub("__at__", "@", addr) |
