HTML::FormFu::Filter::HTMLEscape - filter escaping HTML


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

Index


Code Index:

NAME

Top

HTML::FormFu::Filter::HTMLEscape - filter escaping HTML

DESCRIPTION

Top

HTML escaping filter.

AUTHOR

Top

Carl Franks, cfranks@cpan.org

Based on the original source code of HTML::Widget::Filter::HTMLEscape, 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::HTMLEscape;

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

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

    return if !defined $value;

    $value =~ s/&(?!(amp|lt|gt|quot);)/&/g;
    $value =~ s/</&lt;/g;
    $value =~ s/>/&gt;/g;
    $value =~ s/"/&quot;/g;

    return $value;
}

__PACKAGE__->meta->make_immutable;

1;

__END__