[Python-checkins] python/nondist/peps pep2html.py,1.36,1.37

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
Tue, 28 May 2002 08:46:26 -0700


Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv32476

Modified Files:
	pep2html.py 
Log Message:
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.


Index: pep2html.py
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** pep2html.py	4 Apr 2002 16:13:32 -0000	1.36
--- pep2html.py	28 May 2002 15:46:24 -0000	1.37
***************
*** 102,105 ****
--- 102,128 ----
  
  
+ 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&#64;%s?subject=PEP%%20%s">'
+             '%s&#32;&#97;t&#32;%s</a>'
+             % (parts[0], parts[1], pepno, parts[0], parts[1]))
+ 
+ 
  def fixfile(infile, outfile):
      basename = os.path.basename(infile)
***************
*** 167,173 ****
              for addr in v.split():
                  if '@' in addr:
!                     mailtos.append(
!                         '<a href="mailto:%s?subject=PEP%%20%s">%s</a>' %
!                         (addr, pep, addr))
                  elif addr.startswith('http:'):
                      mailtos.append(
--- 190,198 ----
              for addr in v.split():
                  if '@' in addr:
!                     if k.lower() == 'discussions-to':
!                         m = linkemail(addr, pep)
!                     else:
!                         m = fixemail(addr, pep)
!                     mailtos.append(m)
                  elif addr.startswith('http:'):
                      mailtos.append(
***************
*** 230,235 ****
                      continue
                  elif parts and '@' in parts[-1]:
!                     # This is a pep email address line, so hyperlink it
!                     url = '<a href="mailto:%s">%s</a>' % (parts[-1], parts[-1])
                      if need_pre:
                          print >> fo, '<pre>'
--- 255,260 ----
                      continue
                  elif parts and '@' in parts[-1]:
!                     # This is a pep email address line, so filter it.
!                     url = fixemail(parts[-1], pep)
                      if need_pre:
                          print >> fo, '<pre>'