line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
package Jifty::DBI::Filter::URI; |
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'Jifty::DBI::Filter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
7
|
1
|
|
|
1
|
|
6
|
use URI; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
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
|
6
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
13
|
my $value_ref = $self->value_ref; |
26
|
3
|
100
|
66
|
|
|
53
|
return unless ref $$value_ref and $$value_ref->isa('URI'); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
8
|
$$value_ref = $$value_ref->as_string; |
29
|
1
|
|
|
|
|
154
|
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
|
|
|
|
|
16
|
my $value_ref = $self->value_ref; |
43
|
3
|
100
|
66
|
|
|
35
|
return unless defined $$value_ref and length $$value_ref; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
15
|
$$value_ref = URI->new($$value_ref); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SEE ALSO |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L, L |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|