GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
HTML::Email::Obfuscate(3) User Contributed Perl Documentation HTML::Email::Obfuscate(3)

HTML::Email::Obfuscate - Obfuscated HTML email addresses that look normal

"Don't put emails directly on the page, they will be scraped"

Stuff that, I'm sick of looking at "bob at smith dot com". Why can't we just write emails in a way that looks normal to people, but is very, very difficult to scrape off. Most email scrapers only use very very simple parsing methods. And it isn't as if it is hard to just do.

  # Before we search for email addresses...
  $page =~ s/\s+at\s+/@/g;
  $page =~ s/\s+dot\s+/./g;

This is an arms war dammit, and I want nukes!

This module was written during OSDC/YAPC.AU to demonstrate how quick and easy it is to write a basic module and put it on CPAN. The code was written in about 40 minutes, the documentation was added during a break period before drinks and dinner, and the packing and test files were added during the python keynote (significant whitespace... ew...).

This module starts by applying a fairly basic set of character escapes to avoid the most basic scrapers, and then layers more and more crap on randomly, so that any scraper will need to implement more and more of a full web browser, while keeping the email looking "normal" to anyone browsing.

I've only scraped the surface of what we can achieve, and I'll leave it to others to submit patches to improve it from here on.

This is a pretty simple module.

First, create an obfuscator object. This is just a simple object that holds some preferences about how extreme you want to be about the obfuscation.

  # Create a default obfuscation object
  my $Email = HTML::Email::Obfuscate->new;

Now to turn a normal email string into an obfuscated and fully escaped HTML one, just provide it to the escape_html method.

  # Obfuscate my email address
  my $html = $Email->escape_html( 'cpan@ali.as' );

And we get something like this

  ***Example here once I get a chance to run it***

The defaults are fairly insane, so for people that just want veeeery simple escaping, we'll provide a lite version.

  # Create a "lite" obfuscator
  my $Email = HTML::Email::Obfuscate->new( lite => 1 );
  
  # Access the lite escape method directly, regardless of the
  # obfuscator's constructor params.
  my $html = $Email->escape_html_lite( 'cpan@ali.as' );

For the more serious people, we can also add some more extreme measures that are probably not going to be compatible with everything, such as JavaScript. :/

  # Allow the obfuscator to use JavaScript
  my $Email = HTML::Email::Obfuscator->new( javascript => 1 );

Best not to use that unless you have a JavaScript-capable browser.

I think that just about covers it, and my 7 minute lightning talk is probably almost up.

The "new" constructor creates a new obfuscation object, which use can then use to obfuscate as many email addresses as you like, at whatever severity you want it to be done.

It takes two optional parameters.

If you set the 'javascript' param, the obfuscator will add JavaScript obfuscation (possibly, and randomly) to the mix of obfuscation routines.

If you set the 'lite' param, the obfuscator will only use the most basic form of escaping, which will only fool scanner that don't do HTML entity decoding. Setting 'lite' implies that JavaScript should not be used, even if you explicitly try to turn it on.

Returns a new "HTML::Email::Obfuscate" object.

On an otherwise normal obfuscator, the "escape_html_lite" method provides direct access to the lite method for obfuscating emails.

Returns a HTML string, or "undef" if passed no params, or and undefined param.

The "escape_html" method obfuscates an email according to the params provided to the constructor.

Returns a HTML string, or "undef" if passed no params, or and undefined param.

OK, other than compile testing, I admit that I haven't really done anything significant in the way of testing. I mean, there was SUCH an interesting python talk on, and how on earth do you test something that has randomised output. :/

So yeah, it would be nice to write some better tests.

Bugs should be reported via the CPAN bug tracker at

<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-Email-Obfuscate>

For other issues, or commercial enhancement or support, contact the author.

Adam Kennedy <adamk@cpan.org>

Thank you to Phase N (<http://phase-n.com/>) for permitting the open sourcing and release of this distribution.

Copyright 2004 - 2006 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

2006-09-04 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.