Widget/Filter/HTMLEscape.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 23 CC 2 SCAR 12.8
CC
2
Cov
0%
filter
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.6
1 package HTML::Widget::Filter::HTMLEscape;
2  
3 use warnings;
4 use strict;
5 use base 'HTML::Widget::Filter';
6  
7 =head1 NAME
8  
9 HTML::Widget::Filter::HTMLEscape - HTML Escaping Filter
10  
11 =head1 SYNOPSIS
12  
13 my $f = $widget->filter( 'HTMLEscape', 'foo' );
14  
15 =head1 DESCRIPTION
16  
17 HTML Escaping Filter.
18  
19 =head1 METHODS
20  
21 =head2 filter
22  
23 =cut
24  
25 sub filter {
26 my ( $self, $value ) = @_;
27 return unless defined $value;
28 $value =~ s/&(?!(amp|lt|gt|quot);)/&/g;
29 $value =~ s/</&lt;/g;
30 $value =~ s/>/&gt;/g;
31 $value =~ s/\"/&quot;/g;
32 return $value;
33 }
34  
35 =head1 BUGS
36  
37 L<HTML::Element> now checks for, and refuses to escape already-escaped
38 characters. This means that if you wish to double-escape characters, you must
39 now do it yourself.
40  
41 =head1 AUTHOR
42  
43 Lyo Kato, C<lyo.kato@gmail.com>
44  
45 =head1 LICENSE
46  
47 This library is free software, you can redistribute it and/or modify it under
48 the same terms as Perl itself.
49  
50 =cut
51  
52 1;