If you want to allow some HTML but not all, you can add a set of rules to allow arbitrary elements and attributes:
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Restrict;
my $hr = HTML::Restrict->new();
# use default rules to start with (strip away all HTML)
my $processed = $hr->process('i am bold');
# $processed now equals: i am bold
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Restrict;
my $hr = HTML::Restrict->new();
$hr->set_rules({
b => [],
img => [qw( src alt )]
});
my $html = q[hello];
my $processed = $hr->process( $html );
# $processed now equals: hello
This has now been released as Open Source software and is available on the CPAN


1 comments:
Hi,
just wanted to say that it's awesome.
Post a Comment