| 1 | package Rose::HTML::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 43 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 43 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 6 | 43 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 43 | our @EXPORT_OK = | |||||||||||||||||||||||||||||||||||||||||
| 9 | qw(escape_html unescape_html escape_uri escape_uri_component | ||||||||||||||||||||||||||||||||||||||||||
| 10 | encode_entities strip_html html_attrs_string); | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 43 | our %EXPORT_TAGS = | |||||||||||||||||||||||||||||||||||||||||
| 13 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 14 | all => | ||||||||||||||||||||||||||||||||||||||||||
| 15 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 16 | qw(escape_html unescape_html escape_uri escape_uri_component | ||||||||||||||||||||||||||||||||||||||||||
| 17 | encode_entities) | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 43 | ▶ | use HTML::Entities(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 43 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 43 | ▶ | if(exists $ENV{'MOD_PERL'} && require mod_perl && $mod_perl::VERSION < 1.99) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $ENV{"MOD_PERL"} and require mod_perl and $mod_perl::VERSION < "1.99"
exists $ENV{"MOD_PERL"} and require mod_perl
MC/DC0%0/3
exists $ENV{"MOD_PERL"} and require mod_perl and $mod_perl::VERSION < "1.99"
exists $ENV{"MOD_PERL"}
require mod_perl
$mod_perl::VERSION < "1.99"
Truth table25%1/4
A and B and C
A= exists $ENV{"MOD_PERL"}B= require mod_perlC= $mod_perl::VERSION < "1.99"
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | require Apache::Util; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | #*escape_html = \&HTML::Entities::encode; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | *escape_html = \&encode_entities; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | *unescape_html = \&HTML::Entities::decode; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | *escape_uri_component = \&Apache::Util::escape_uri; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | else | ||||||||||||||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | #*escape_html = \&HTML::Entities::encode; | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 43 | *escape_html = \&encode_entities; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 43 | *unescape_html = \&HTML::Entities::decode; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 43 | *escape_uri_component = \&URI::Escape::uri_escape; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 43 | our $VERSION = '0.011'; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 1094 | ▶ | sub encode_entities { HTML::Entities::encode_entities($_[0], @_ > 1 ? $_[1] : '<>&"') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_entities: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | sub escape_uri | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_uri: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | URI::Escape::uri_escape($_[0], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | (@_ > 1) ? (defined $_[1] ? $_[1] : ()) : q(^A-Za-z0-9\-_.,'!~*#?&()/?@\:\[\]=)); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | sub html_attrs_string | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 61 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html_attrs_string: called CC=6 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 61 | my %attrs; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 61 | ▶ | if(@_ == 1 && ref $_[0] eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 61 | %attrs = %{$_[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ▶ | elsif(@_ && @_ % 2 == 0) | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ and @_ % 2 == 0
MC/DC0%0/2
@_ and @_ % 2 == 0
@_
@_ % 2 == 0
Truth table0%0/3
A and B
A= @_B= @_ % 2 == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | %attrs = @_; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 61 | ▶ | return '' unless(keys %attrs); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 43 | return ' ' . join(' ', map { $_ . q(=") . escape_html($attrs{$_}) . q(") } | |||||||||||||||||||||||||||||||||||||||||
| 67 | sort keys(%attrs)); | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | sub strip_html | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strip_html: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my($text) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | # XXX: dumb for now... | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $text =~ s{<[^>]*?/?>}{}g; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 43 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | __END__ | ||||||||||||||||||||||||||||||||||||||||||