NAME
Template::Plugin::Filter::HTMLScrubber - Filter Plugin for using HTML::Scrubber in Template , and some additional function;
VERSION
0.03
SYNOPSIS
[% USE Filter.HTMLScrubber %]
[% html_text | html_scrubber %]
[% html_text | html_scrubber(['-img']) %]
DESCRIPTION
This plugin provides an HTML::Scrubber::scrub method to Template Toolkit Filter , and enables to specify the scrub level and tags at every parts.
The default usage.
my $html_text = q[
<img src="http://your.favorite.photo.jpg" />
<hr>
<script>alert('NyanPome!')</script>
];
[% USE Filter.HTMLScrubber %]
[% html_text | html_scrubber %]
Another function of this plugin module enable you to specify allow/deny tags at every part.
#deny 'img' tag from default scrub level.
[% html_text_deny_image | html_scrubber(['-img']) %]
#allow 'script' and 'style' tags to default scrub level.
[% html_text_loose | html_scrubber(['+script' , '+style']) %]
You can setup the scrubbed tags, then should set "base" config.
my $setup = {
base => {
allow => [qw| br hr b a u del i |],
rules => [
script => 0,
span => {
style => qr{^(?!(?:java)?script)}i,
class => qr{^(?!(?:java)?script)}i,
'*' => 0,
},
img => {
src => qr{^(?!(?:java)?script)}i,
alt => qr{^(?!(?:java)?script)}i,
title => qr{^(?!(?:java)?script)}i,
class => qr{^(?!(?:java)?script)}i,
'*' => 0,
},
],
default => [
0 => {
'*' => 1,
'href' => qr{^(?!(?:java)?script)}i,
'src' => qr{^(?!(?:java)?script)}i,
}
],
}
};
[% USE Filter.HTMLScrubber setup %]
[% html_text | html_scrubber %]
Furthermore, you can specify various level of scrubbing. When you call html_scrubber,you code the level.
my $setup = {
base => .....,
strict => .....
loose => .....
};
[% USE Filter.HTMLScrubber setup %]
[% html_text1 | html_scrubber('strict') %]
[% html_text2 | html_scrubber('loose',['-img']) %]
METHODS
init
Overrided method. See more detail Template::Plugin::Filter
filter
Overrided method. See more detail Template::Plugin::Filter
CONFIGURATION AND ENVIRONMENT
Template::Plugin::Filter::HTMLScrubber requires no configuration files or environment variables.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to bug-template-plugin-filter-htmlscrubber@rt.cpan.org, or through the web interface at http://rt.cpan.org.
SEE ALSO
HTML::Scrubber, HTML::Plugin::Filter
AUTHOR
Yu Isobe <yupug at cpan.org>
THANKS
Toru Yamaguchi
LICENCE AND COPYRIGHT
Copyright (c) 2006, Yu Isobe <yupug at cpan.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.