[Zope] Re: Simple way to obfuscate email addresses to foilspambots?

Erik Myllymaki erik.myllymaki at aviawest.com
Fri Sep 12 14:42:13 EDT 2003


> ----- Original Message ----- 
> From: "Josef Albert Meile" <jmeile at hotmail.com>
> To: <zope at zope.org>
> Sent: Friday, September 12, 2003 9:35 AM
> Subject: [Zope] Re: Simple way to obfuscate email addresses to foil
> spambots?
>
>
> > >Does anyone have any suggestions as the best way to, within Zope,
> > >obfuscate email addresses such that, when passed an email, a script
> > >obfuscates it from being picked up by email-address
> > >collecting robots?
> > >
> > >Or any other creative anti-spam tricks.. I work at an educational
> > >nonprofit and our spam load seems to be increasing exponentially..
> >
> > In the past, I was using a Javascript that I translated to
> > python:
> > http://www.zope.org/Members/jmeile/email%20encoder
> >
> > But for some reason it shows the real address on the html source on
> > netscape 4.x under zope. Without zope, the javascript works perfect
> > also in netscape 4.x.
> >
> > Anyway, now I'm using this on the body of my pages:
> >
> > <script language="JavaScript">jemail("username","domain","");</script>
> >
> > or
> >
> > <script
> > language="JavaScript">jemail("username","domain","linkText");</script>
> >
> > If you use the first call, then the text of the email link will be the
> > e-mail
> > address. The second one allows you to specify a text, ie: 'Contact us'.
> >
> > And the javascript code is:
> >
> > function jemail(user, domain, text){
> >   if (text=='')
> >     document.write('<a href="'+'mailto:'+user+'@'+domain+'">'+user+'@'
> > +domain+'</a>')
> >   else
> >     document.write('<a
href="'+'mailto:'+user+'@'+domain+'">'+text+'</a>')
> > }
> >
> > You can combine it with dtml like this:
> >
> > def splitMail(myEmail):
> >   return myEmail.split('@')
> >
> > Then:
> >
> > <dtml-let splitedMail="splitMail(myEmail)" username="myEmail[0]"
> > domain="myEmail[1]">
> > <script
> >
>
language="JavaScript">jemail("&dtml-username;","&dtml-domain;","linkText");<
> /script>
> > </dtml/let>
> >
> > And if you are using Zclasses or python Classes, then you can store
> > the encoded email as an attribute and you won't have to write the
> > ugly and long code again.
> >
> > I'd like to use zpt, but I haven't had time to think about it.
> >
> > Regards,
> > Josef
>
> Make a Python Script called antispam(stolen from HTMLgen.py):
>
> parameters: address
> ---------------------------------------------------
> import string
> from whrandom import choice
>
> buffer = map(None, address)
> for i in range(0, len(address), choice((2,3,4))):
>     buffer[i] = '&#%d;' % ord(buffer[i])
>
> return string.join(buffer,'')
> ---------------------------------------------------
>
> on your pages, use mailtos like this:
>
> <a href=mailto:<dtml-var expr="antispam('myname at mydomain.com')"> >My
> Name</a>


or, even better:

-----------------------------------------------------
import string
from whrandom import choice

buffer = map(None, address)
for i in range(0, len(address), choice((2,3,4))):
    buffer[i] = '&#%d;' % ord(buffer[i])

return '<A HREF="mailto:%s">%s</A>' %
(string.join(buffer,''),string.join(buffer,''))
-------------------------------------------------------------

and then use:

<dtml-var expr="antispam('myname at mydomain.com')">

on your pages...




More information about the Zope mailing list