|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Template::Plugin::Filter::Base64;  | 
| 
2
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
67494
 | 
 use 5.008001;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
    | 
| 
3
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
12
 | 
 use strict;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
40
 | 
    | 
| 
4
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
9
 | 
 use warnings;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
59
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
6
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
1006
 | 
 use Template::Plugin::Filter;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12041
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
64
 | 
    | 
| 
7
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
13
 | 
 use base qw( Template::Plugin::Filter );  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
133
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
1154
 | 
 use Encode;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20532
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
148
 | 
    | 
| 
10
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
909
 | 
 use MIME::Base64 qw(encode_base64);  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1128
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
134
 | 
    | 
| 
11
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
984
 | 
 use HTML::Entities qw(encode_entities_numeric);  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11286
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
692
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = "0.07";  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub init {  | 
| 
16
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
  
0
  
 | 
81225
 | 
     my ($self) = @_;  | 
| 
17
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
     $self->{_DYNAMIC} = 1;  | 
| 
18
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
32
 | 
     $self->install_filter('b64');  | 
| 
19
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
306
 | 
     return $self;  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub filter {  | 
| 
23
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
  
0
  
 | 
600
 | 
     my ($self, $text, $args, $conf) = @_;  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
25
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
19
 | 
     $conf = $self->merge_config($conf);  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
27
 | 
7
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
99
 | 
     if ($conf->{trim}) {  | 
| 
28
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
         $text =~ s/^\s+//ms;  | 
| 
29
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
37
 | 
         $text =~ s/\s+$//ms;  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
31
 | 
7
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
23
 | 
     if($conf->{safeurl}){  | 
| 
32
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
         return MIME::Base64::encode_base64url($text);  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
35
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
     my @encode_args = ();  | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
38
 | 
6
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
21
 | 
     if ($conf->{use_html_entity}) {  | 
| 
39
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
         my $charset = $conf->{use_html_entity};  | 
| 
40
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
         if($charset){  | 
| 
41
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
             $text = decode($charset, $text)  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
43
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3035
 | 
         $text = Encode::encode('UTF-8',$text);  | 
| 
44
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
268
 | 
         Encode::_utf8_on($text);  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
         $text = encode_entities_numeric($text);  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }else{  | 
| 
49
 | 
5
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
22
 | 
         utf8::encode($text) if utf8::is_utf8($text);  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
51
 | 
6
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
94
 | 
     if ($conf->{dont_broken_into_lines_each_76_char}) {  | 
| 
52
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
         push @encode_args, '';  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
55
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
     unshift @encode_args, $text;  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
57
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
     my $encoded = &encode_base64(@encode_args);  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
59
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
39
 | 
     return $encoded  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |