From 8400ef771c1b7724082f1e6c8f1717a366a981d2 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Tue, 28 May 2002 15:46:24 +0000 Subject: [PATCH] Change the handling of email addresses to be somewhat more difficult for spam harvesters to collect, and limit those that are actually turned into hyperlinks. --- pep2html.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/pep2html.py b/pep2html.py index b31b59b02..47cf1be1e 100755 --- a/pep2html.py +++ b/pep2html.py @@ -100,6 +100,29 @@ def fixanchor(current, match): return cgi.escape(match.group(0)) # really slow, but it works... + +NON_MASKED_EMAILS = [ + 'peps@python.org', + 'python-list@python.org', + 'python-dev@python.org', + ] + +def fixemail(address, pepno): + if address.lower() in NON_MASKED_EMAILS: + # return hyperlinked version of email address + return linkemail(address, pepno) + else: + # return masked version of email address + parts = address.split('@', 1) + return '%s at %s' % (parts[0], parts[1]) + + +def linkemail(address, pepno): + parts = address.split('@', 1) + return ('' + '%s at %s' + % (parts[0], parts[1], pepno, parts[0], parts[1])) + def fixfile(infile, outfile): basename = os.path.basename(infile) @@ -166,9 +189,11 @@ def fixfile(infile, outfile): mailtos = [] for addr in v.split(): if '@' in addr: - mailtos.append( - '%s' % - (addr, pep, addr)) + if k.lower() == 'discussions-to': + m = linkemail(addr, pep) + else: + m = fixemail(addr, pep) + mailtos.append(m) elif addr.startswith('http:'): mailtos.append( '%s' % (addr, addr)) @@ -229,8 +254,8 @@ def fixfile(infile, outfile): line, 1), continue elif parts and '@' in parts[-1]: - # This is a pep email address line, so hyperlink it - url = '%s' % (parts[-1], parts[-1]) + # This is a pep email address line, so filter it. + url = fixemail(parts[-1], pep) if need_pre: print >> fo, '
'
                         need_pre = 0