HTML::Widget::Filter::HTMLEscape - HTML Escaping Filter


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

Index


Code Index:

NAME

Top

HTML::Widget::Filter::HTMLEscape - HTML Escaping Filter

SYNOPSIS

Top

    my $f = $widget->filter( 'HTMLEscape', 'foo' );

DESCRIPTION

Top

HTML Escaping Filter.

METHODS

Top

filter

BUGS

Top

HTML::Element now checks for, and refuses to escape already-escaped characters. This means that if you wish to double-escape characters, you must now do it yourself.

AUTHOR

Top

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-Widget documentation Contained in the HTML-Widget distribution.
package HTML::Widget::Filter::HTMLEscape;

use warnings;
use strict;
use base 'HTML::Widget::Filter';

sub filter {
    my ( $self, $value ) = @_;
    return unless defined $value;
    $value =~ s/&(?!(amp|lt|gt|quot);)/&/g;
    $value =~ s/</&lt;/g;
    $value =~ s/>/&gt;/g;
    $value =~ s/\"/&quot;/g;
    return $value;
}

1;