There are many ways to hide an email address within an HTML-page. Some use HTML entities or URI encoding. Others use JavaScript. I guess that the Spammer's harvesting robots can easily decode HTML entities or URI encoding (with Perl), but for JS they would need a JS-interpreter. So using JS seems a better way. The snippet uses a regex to replace the whole anchor (<a ...>...</a>) with a JS document.write of the splitted text. Maybe this is useful for someboby. Maybe you can direct me to a better regex. I've a version that uses HTML::TokeParser (less performant) instead, contact me if you are interested.
$html =~ s|(<[aA]\b # <a
[^<>]*\b # any attributes
[hH][rR][eE][fF]=\"? # href=
[mM][aA][iI][lL][tT][oO]: # mailto:
([^\"\s<>]+) # EMAIL
\"? # href closed
[^<>]* # any attributes
> # anchor closed
(.+?) # TEXT
</[aA]>) # </a>
|antispamize($1, $2, $3)|sgex;
sub antispamize {
my($anchor, $email, $text) = @_;
#$email =~ s/@/{at}/g;
#$text =~ s/@/{at}/g;
my $anchor = "<script language=\"JavaScript\">document.write('" .
join("'+'", $anchor =~ /(.{1,4})/g) .
"');</script>";
## may be you want to add this
#$anchor .= "<noscript>$text ($email)</noscript>";
return $anchor;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.