| Next: HTML::Balance | Previous: conf::SiteConfig | [Table of Contents] |
HTML::AddNoFollow - A simple module to add 'rel="nofollow"' to hyperlinks.
#!/usr/bin/perl -w
use HTML::AddNoFollow;
use strict;
my $html = q[ <a href="http://foo.com/">Test</a> ];
my $cgi = new CGI;
$cgi->param( "html", $html );
$cgi = HTML::AddNoFollow::sanitize( $cgi );
If you wish to display user supplied HTML text you may well find that people submit links inside HTML, designed to increase their page-rank.
This module automatically defeats those people by adding the 'rel="nofollow"' to the hyperlinks.
The module will correctly modify all input which is accessed via a CGI object - if you wish to only filter one particular variable then you must create a fake CGI object, as shown in the example.
This code was achieved via a discussion on Perlmonks.org, via a question I submitted. For all the discussion please see the following URI:
http://www.perlmonks.org/?node_id=452790
Sanitize a single HTML String.
Steve Kemp
http://www.steve.org.uk/
Copyright (c) 2005 by Steve Kemp. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.