line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jifty::DBI::Filter::base64; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw|Jifty::DBI::Filter|; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
7
|
1
|
|
|
1
|
|
6
|
use Encode qw(encode_utf8 is_utf8); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
8
|
1
|
|
|
1
|
|
1095
|
use MIME::Base64 (); |
|
1
|
|
|
|
|
1543
|
|
|
1
|
|
|
|
|
213
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Jifty::DBI::Filter::base64 - Encodes data as base64 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This filter allow you to store arbitrary data in a column of type |
17
|
|
|
|
|
|
|
'text'. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 encode |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
If value is defined, then encodes it using L after |
22
|
|
|
|
|
|
|
passing it through L. Does nothing if value is not |
23
|
|
|
|
|
|
|
defined. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub encode { |
28
|
3
|
|
|
3
|
1
|
8
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
16
|
my $value_ref = $self->value_ref; |
31
|
3
|
50
|
|
|
|
38
|
return unless defined $$value_ref; |
32
|
|
|
|
|
|
|
|
33
|
3
|
100
|
|
|
|
35
|
$$value_ref = MIME::Base64::encode_base64( |
34
|
|
|
|
|
|
|
is_utf8($$value_ref) ? encode_utf8($$value_ref) : $$value_ref |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
40
|
return 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 decode |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
If value is defined, then decodes it using |
43
|
|
|
|
|
|
|
L, otherwise do nothing. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub decode { |
48
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $value_ref = $self->value_ref; |
51
|
0
|
0
|
|
|
|
|
return unless defined $$value_ref; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$$value_ref = MIME::Base64::decode_base64($$value_ref); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SEE ALSO |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
L, L |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |