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.
This commit is contained in:
parent
06f95c998b
commit
8400ef771c
35
pep2html.py
35
pep2html.py
|
@ -100,6 +100,29 @@ def fixanchor(current, match):
|
||||||
return cgi.escape(match.group(0)) # really slow, but it works...
|
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 ('<a href="mailto:%s@%s?subject=PEP%%20%s">'
|
||||||
|
'%s at %s</a>'
|
||||||
|
% (parts[0], parts[1], pepno, parts[0], parts[1]))
|
||||||
|
|
||||||
|
|
||||||
def fixfile(infile, outfile):
|
def fixfile(infile, outfile):
|
||||||
basename = os.path.basename(infile)
|
basename = os.path.basename(infile)
|
||||||
|
@ -166,9 +189,11 @@ def fixfile(infile, outfile):
|
||||||
mailtos = []
|
mailtos = []
|
||||||
for addr in v.split():
|
for addr in v.split():
|
||||||
if '@' in addr:
|
if '@' in addr:
|
||||||
mailtos.append(
|
if k.lower() == 'discussions-to':
|
||||||
'<a href="mailto:%s?subject=PEP%%20%s">%s</a>' %
|
m = linkemail(addr, pep)
|
||||||
(addr, pep, addr))
|
else:
|
||||||
|
m = fixemail(addr, pep)
|
||||||
|
mailtos.append(m)
|
||||||
elif addr.startswith('http:'):
|
elif addr.startswith('http:'):
|
||||||
mailtos.append(
|
mailtos.append(
|
||||||
'<a href="%s">%s</a>' % (addr, addr))
|
'<a href="%s">%s</a>' % (addr, addr))
|
||||||
|
@ -229,8 +254,8 @@ def fixfile(infile, outfile):
|
||||||
line, 1),
|
line, 1),
|
||||||
continue
|
continue
|
||||||
elif parts and '@' in parts[-1]:
|
elif parts and '@' in parts[-1]:
|
||||||
# This is a pep email address line, so hyperlink it
|
# This is a pep email address line, so filter it.
|
||||||
url = '<a href="mailto:%s">%s</a>' % (parts[-1], parts[-1])
|
url = fixemail(parts[-1], pep)
|
||||||
if need_pre:
|
if need_pre:
|
||||||
print >> fo, '<pre>'
|
print >> fo, '<pre>'
|
||||||
need_pre = 0
|
need_pre = 0
|
||||||
|
|
Loading…
Reference in New Issue