line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Templ::Spec::HTML; |
2
|
1
|
|
|
1
|
|
3
|
use base 'Templ::Spec::XML'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
327
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Exporter; |
5
|
|
|
|
|
|
|
push @ISA, 'Exporter'; |
6
|
|
|
|
|
|
|
@EXPORT = qw(uri_escape); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use strict; |
9
|
|
|
|
|
|
|
use warnings; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Templ (); # Loads all modules, but doesn't import anything |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
add Templ::Header 'use Templ::Spec::HTML;'; |
14
|
|
|
|
|
|
|
add Templ::Tag::Filter '%' => 'uri_escape'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $url_regex = qr/[^A-Za-z0-9_\.~-]/;; |
17
|
|
|
|
|
|
|
my %url_charmap = ( |
18
|
|
|
|
|
|
|
map { chr($_) => sprintf( '%%%02X', $_ ); } |
19
|
|
|
|
|
|
|
grep { chr($_) =~ m/^$url_regex$/ } |
20
|
|
|
|
|
|
|
0 .. 255 |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub uri_escape { |
24
|
|
|
|
|
|
|
my $str = shift; |
25
|
|
|
|
|
|
|
return '' unless defined $str; |
26
|
|
|
|
|
|
|
$str =~ s/($url_regex)/$url_charmap{$1}/gs; |
27
|
|
|
|
|
|
|
$str =~ s/\%20/+/gs; |
28
|
|
|
|
|
|
|
return $str; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |