blib/lib/Templ/Spec/HTML.pm

filter: Statementstmt 100% 29 / 29 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 94.7% 36 / 38 CC 2 SCAR 2.5
CC
2
Cov
97%
uri_escape
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« blib/lib/Templ/Tag/Print.pm ↑ Summary blib/lib/Templ/Parser/Print.pm »
1 package Templ::Spec::HTML;
2 1 ▶use base 'Templ::Spec::XML';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 push @ISA, 'Exporter';
6 1 @EXPORT = qw(uri_escape);
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Templ (); # Loads all modules, but doesn't import anything
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 add Templ::Header 'use Templ::Spec::HTML;';
14 1 add Templ::Tag::Filter '%' => 'uri_escape';
15  
16 1 my $url_regex = qr/[^A-Za-z0-9_\.~-]/;;
17 my %url_charmap = (
18 190 map { chr($_) => sprintf( '%%%02X', $_ ); }
19 1 grep { chr($_) =~ m/^$url_regex$/ }
20 0 .. 255
21 );
22  
23 sub uri_escape {
24 2 ▶ my $str = shift;
Subroutine uri_escape: called CC=2 SCAR=7.0
Pod undocumented
25 2 ▶ return '' unless defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 0 2 2
26 2 $str =~ s/($url_regex)/$url_charmap{$1}/gs;
27 2 $str =~ s/\%20/+/gs;
28 2 return $str;
29 }
30  
31 1 1;
« blib/lib/Templ/Tag/Print.pm ↑ Summary blib/lib/Templ/Parser/Print.pm »