HTML::FormFu::Filter::HTMLScrubber - filter removing HTML markup


HTML-FormFu documentation Contained in the HTML-FormFu distribution.

Index


Code Index:

NAME

Top

HTML::FormFu::Filter::HTMLScrubber - filter removing HTML markup

DESCRIPTION

Top

Remove HTML markup using HTML::Scrubber.

All the functionality of HTML::Scrubber can be accessed using this module, other than the process directive (which has a name clash with the HTML::FormFu::Filter framework).

For details of the filtering functionality see allow in HTML::Scrubber, comment in HTML::Scrubber, default in HTML::Scrubber, rules in HTML::Scrubber and script in HTML::Scrubber

AUTHOR

Top

Carl Franks, cfranks@cpan.org

Extended by Nigel Metheringham, nigelm@cpan.org

Based on the original source code of HTML::Widget::Filter::HTMLStrip, by Lyo Kato, lyo.kato@gmail.com

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


HTML-FormFu documentation Contained in the HTML-FormFu distribution.

package HTML::FormFu::Filter::HTMLScrubber;

use Moose;
extends 'HTML::FormFu::Filter';

use Clone ();

has allow   => ( is => 'rw', traits  => ['Chained'] );
has comment => ( is => 'rw', traits  => ['Chained'] );
has default => ( is => 'rw', traits  => ['Chained'] );
has rules   => ( is => 'rw', traits  => ['Chained'] );
has script  => ( is => 'rw', traits  => ['Chained'] );

use HTML::Scrubber;

sub filter {
    my ( $self, $value ) = @_;

    return if !defined $value;

    my %params = ( allow => 0 );
    foreach (qw(allow comment default rules script)) {
        my $val = $self->$_;
        $params{$_} = $val if ( defined($val) );
    }

    my $scrubber = HTML::Scrubber->new(%params);

    return $scrubber->scrub($value);
}

sub clone {
    my $self = shift;

    my $clone = $self->SUPER::clone(@_);

    $clone->allow( Clone::clone $self->allow )
        if ref $self->allow;

    return $clone;
}

__PACKAGE__->meta->make_immutable;

1;

__END__