blib/lib/Template/Plugin/Filter/Base64.pm

filter: Statementstmt 100% 49 / 49 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 95.7% 68 / 71 SCAR 17.9
CC
6
Cov
98%
filter
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.0
↑ Summary Build »
1 package Template::Plugin::Filter::Base64;
2 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Template::Plugin::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use base qw( Template::Plugin::Filter );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use MIME::Base64 qw(encode_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use HTML::Entities qw(encode_entities_numeric);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 our $VERSION = "0.06";
14  
15 sub init {
16 5 ▶ my ($self) = @_;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
17 5 $self->{_DYNAMIC} = 1;
18 5 $self->install_filter('b64');
19 5 return $self;
20 }
21  
22 sub filter {
23 5 ▶ my ($self, $text, $args, $conf) = @_;
Subroutine filter: called CC=6 SCAR=17.9
Pod undocumented
24  
25 5 $conf = $self->merge_config($conf);
26
27 5 ▶ if ($conf->{trim}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"trim"}) 4 1 5
28 4 $text =~ s/^\s+//ms;
29 4 $text =~ s/\s+$//ms;
30 }
31 5 ▶ if($conf->{safeurl}){
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"safeurl"}) 1 4 5
32 1 return MIME::Base64::encode_base64url($text);
33 }
34  
35 4 my @encode_args = ();
36  
37
38 4 ▶ if ($conf->{use_html_entity}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"use_html_entity"}) 1 3 4
39 1 my $charset = $conf->{use_html_entity};
40 1 ▶ if($charset){
Branch: 1 branch
BranchTrueFalseTotal
if ($charset) 1 0 1
41 1 $text = decode($charset, $text)
42 }
43 1 $text = Encode::encode('UTF-8',$text);
44
45 1 Encode::_utf8_on($text);
46 1 $text = encode_entities_numeric($text);
47  
48 }
49 4 ▶ if ($conf->{dont_broken_into_lines_each_76_char}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"dont_broken_into_lines_each_76_char"}) 2 2 4
50 2 push @encode_args, '';
51 }
52
53 4 unshift @encode_args, $text;
54  
55 4 my $encoded = &encode_base64(@encode_args);
56  
57 4 return $encoded
58 }
59  
60 2 1;
61 __END__
↑ Summary Build »