line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Escape; |
2
|
3
|
|
|
3
|
|
39877
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
68
|
|
3
|
3
|
|
|
3
|
|
9
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
51
|
|
4
|
3
|
|
|
3
|
|
43
|
use 5.008005; |
|
3
|
|
|
|
|
15
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.10'; |
6
|
3
|
|
|
3
|
|
1079
|
use parent qw/Exporter/; |
|
3
|
|
|
|
|
657
|
|
|
3
|
|
|
|
|
12
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $use_xs = 0; |
9
|
|
|
|
|
|
|
if(!exists $INC{'HTML/Escape/PurePerl.pm'}) { |
10
|
|
|
|
|
|
|
my $pp = $ENV{PERL_ONLY}; |
11
|
|
|
|
|
|
|
if (!$pp) { |
12
|
|
|
|
|
|
|
eval { |
13
|
|
|
|
|
|
|
require XSLoader; |
14
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
15
|
|
|
|
|
|
|
$use_xs = 1; |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
if (!__PACKAGE__->can('escape_html')) { |
19
|
|
|
|
|
|
|
## no critic. |
20
|
|
|
|
|
|
|
require 'HTML/Escape/PurePerl.pm' # not to create the namespace |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
2
|
|
|
2
|
0
|
13
|
sub USE_XS () { $use_xs } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT = qw/escape_html/; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
__END__ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=encoding utf8 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
HTML::Escape - Extremely fast HTML escaping |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use HTML::Escape qw/escape_html/; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
escape_html("<^o^>"); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This modules provides a function which escapes HTML's special characters. It |
45
|
|
|
|
|
|
|
performs a similar function to PHP's htmlspecialchars. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This module uses XS for better performance, but it also provides a pure perl |
48
|
|
|
|
|
|
|
version. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 FAQ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over 4 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item Is there also an unescape_html? |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
No. Unescaping HTML requires a lot of code, and we don't want to do it. |
57
|
|
|
|
|
|
|
Please use L<HTML::Entities> for it. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=back |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 BENCHMARK |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Rate HTML::Entities HTML::Escape |
64
|
|
|
|
|
|
|
HTML::Entities 14.0/s -- -91% |
65
|
|
|
|
|
|
|
HTML::Escape 150/s 975% -- |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Goro Fuji |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Tokuhiro Matsuno E<lt>tokuhirom AAJKLFJEF@ GMAIL COME<gt> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L<Text::Xslate>, L<HTML::Entities> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Copyright (C) Tokuhiro Matsuno |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
82
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |