line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
package Jifty::DBI::Filter::URI; |
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use base 'Jifty::DBI::Filter'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
7
|
1
|
|
|
1
|
|
3
|
use URI; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Jifty::DBI::Filter::URI - Encodes uniform resource identifiers |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 encode |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
If the value is a L, encode it to its string |
18
|
|
|
|
|
|
|
form. Otherwise, do nothing. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub encode { |
23
|
3
|
|
|
3
|
1
|
4
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
8
|
my $value_ref = $self->value_ref; |
26
|
3
|
100
|
66
|
|
|
37
|
return unless ref $$value_ref and $$value_ref->isa('URI'); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
7
|
$$value_ref = $$value_ref->as_string; |
29
|
1
|
|
|
|
|
121
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 decode |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
If value is defined, then decode it using |
35
|
|
|
|
|
|
|
L, otherwise do nothing. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub decode { |
40
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
12
|
my $value_ref = $self->value_ref; |
43
|
3
|
100
|
66
|
|
|
34
|
return unless defined $$value_ref and length $$value_ref; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
13
|
$$value_ref = URI->new($$value_ref); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SEE ALSO |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L, L |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|