in reply to Email anti-harvester code

Those tricks are ok for obscuring text-only addresses, but they are useless for real links.

GD, Image::Magick, Gimp, and others can handle text-to-image conversion. HTML::Entities will do the other. The opposition can use that module, too.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Email anti-harvester code
by cpc (Hermit) on Oct 04, 2003 at 05:02 UTC
    Quick and dirty way to do the trick using GD:
    #!/usr/bin/perl -w use GD; use GD::Text; my $gd_text = GD::Text->new() or die GD::Text::error(); $gd_text->set_font(gdSmallFont); $gd_text->set_text("nobody\@perlmonks.org"); my ($w, $h) = $gd_text->get('width', 'height'); my $gd = GD::Image->new($w,$h); $white = $gd->colorAllocate(255,255,255); $black = $gd->colorAllocate(0,0,0); $gd->transparent($white); $gd->string(gdSmallFont, 0, 0, "nobody\@perlmonks.org",$black); binmode STDOUT; print $gd->png;
    perl -l -e "eval pack('h*','072796e647028222d2d202a0e49636f6c61637022292b3');"
      You need to add two things to this graphic: at the html page...

      <img border="0" src="http://localhost/cgi-bin/grafem@il.cgi" alt="this + is my email" width="144" height="13">

      to call the script. And at the end of the script...

      print "Content-type:image/png\n\n"; print $gd->png;
      To fit an image into what was expected (see the content-type).
Re: Re: Email anti-harvester code
by bart (Canon) on Oct 04, 2003 at 09:18 UTC
    No, that's not right. You can safely convert your characters in your links to HTML entities, your browser has to recognize it — in fact, in attributes, the ampersand actually has to be encoded, though in many cases, you can get away without it. But hopefully, email harvesters are too stupid to recognize it. For now.

    For example, that's what I did in the contact info field this node. If there wasn't a limit on the contact info field on this site, it would have been an actual "mailto" link.

    Here's a little snippet to convert the text into numerical entities, ready for pasting into your HTML pages:

    print map "&#$_;", unpack "C*", $text;