Apache2-WebApp-Plugin-Filters
view release on metacpan or search on metacpan
strip_domain_alias
Remove the subdomain (alias) from a domain name.
my $result = $c->plugin('Filters')->strip_domain_alias($domain);
strip_html
Remove all HTML tags and attributes.
my $result = $c->plugin('Filters')->strip_html($markup);
untaint_html
Remove restricted HTML tags and attributes.
my $result = $c->plugin('Filters')->untaint_html($markup);
Supported tags:
a blockquote br dd dl div em font form img input hr h1 h2 h3 h4 h5 h6
label legend li ol option p pre ul script select small span strong style
table tbody tfoot thead tr td
SEE ALSO
Apache2::WebApp, Apache2::WebApp::Plugin, HTML::StripScripts::Parser
lib/Apache2/WebApp/Plugin/Filters.pm view on Meta::CPAN
my $hs = HTML::StripScripts::Parser->new({
Context => 'NoTags',
});
my $text = $hs->filter_html($markup);
$text =~ s/<!--filtered-->//g;
return $text;
}
#----------------------------------------------------------------------------+
# untaint_html($markup)
#
# Remove restricted HTML tags and attributes.
sub untaint_html {
my ( $self, $markup )
= validate_pos( @_,
{ type => OBJECT },
{ type => SCALAR }
);
my $hs = HTML::StripScripts::Parser->new({
AllowHref => 1,
AllowRelURL => 1,
AllowSrc => 1,
lib/Apache2/WebApp/Plugin/Filters.pm view on Meta::CPAN
Remove the subdomain (alias) from a domain name.
my $result = $c->plugin('Filters')->strip_domain_alias($domain);
=head2 strip_html
Remove all HTML tags and attributes.
my $result = $c->plugin('Filters')->strip_html($markup);
=head2 untaint_html
Remove restricted HTML tags and attributes.
my $result = $c->plugin('Filters')->untaint_html($markup);
Supported tags:
a blockquote br dd dl div em font form img input hr h1 h2 h3 h4 h5 h6
label legend li ol option p pre ul script select small span strong style
table tbody tfoot thead tr td
=head1 SEE ALSO
L<Apache2::WebApp>, L<Apache2::WebApp::Plugin>, L<HTML::StripScripts::Parser>
t/002_basic.t view on Meta::CPAN
use Apache::TestUtil;
use Apache::TestRequest qw( GET_BODY );
use Test::More;
ok 1;
my $uri1 = '/app/test/encode_url';
my $uri2 = '/app/test/decode_url';
my $uri3 = '/app/test/strip_domain_alias';
my $uri4 = '/app/test/strip_html';
my $uri5 = '/app/test/untaint_html';
my $data1 = GET_BODY $uri1;
my $data2 = GET_BODY $uri2;
my $data3 = GET_BODY $uri3;
my $data4 = GET_BODY $uri4;
my $data5 = GET_BODY $uri5;
ok t_cmp(
$data1,
'success',
'testing encode_url() method',
t/002_basic.t view on Meta::CPAN
ok t_cmp(
$data4,
'success',
'testing strip_html() method',
);
ok t_cmp(
$data5,
'success',
'testing untaint_html() method',
);
done_testing();
t/app/Basic/Test.pm view on Meta::CPAN
}
sub strip_html {
my ( $self, $c ) = @_;
my $result = $c->plugin('Filters')->strip_html('<html>test</html>');
$self->_success($c) if ($result eq 'test');
}
sub untaint_html {
my ( $self, $c ) = @_;
my $result = $c->plugin('Filters')->untaint_html('<none>test</none>');
$self->_success($c) if ($result eq 'test');
}
sub _success {
my ( $self, $c ) = @_;
$c->request->content_type('text/html');
print "success";
( run in 4.113 seconds using v1.01-cache-2.11-cpan-df04353d9ac )