line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::data; # RFC 2397 |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
368
|
use parent 'URI'; |
|
1
|
|
|
|
|
288
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '5.19'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
512
|
use MIME::Base64 qw(decode_base64 encode_base64); |
|
1
|
|
|
|
|
643
|
|
|
1
|
|
|
|
|
62
|
|
11
|
1
|
|
|
1
|
|
6
|
use URI::Escape qw(uri_unescape); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
572
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub media_type |
14
|
|
|
|
|
|
|
{ |
15
|
9
|
|
|
9
|
1
|
28
|
my $self = shift; |
16
|
9
|
|
|
|
|
24
|
my $opaque = $self->opaque; |
17
|
9
|
50
|
|
|
|
29
|
$opaque =~ /^([^,]*),?/ or die; |
18
|
9
|
|
|
|
|
17
|
my $old = $1; |
19
|
9
|
|
|
|
|
14
|
my $base64; |
20
|
9
|
100
|
|
|
|
34
|
$base64 = $1 if $old =~ s/(;base64)$//i; |
21
|
9
|
100
|
|
|
|
21
|
if (@_) { |
22
|
6
|
|
|
|
|
7
|
my $new = shift; |
23
|
6
|
100
|
|
|
|
13
|
$new = "" unless defined $new; |
24
|
6
|
|
|
|
|
11
|
$new =~ s/%/%25/g; |
25
|
6
|
|
|
|
|
8
|
$new =~ s/,/%2C/g; |
26
|
6
|
100
|
|
|
|
11
|
$base64 = "" unless defined $base64; |
27
|
6
|
|
|
|
|
42
|
$opaque =~ s/^[^,]*,?/$new$base64,/; |
28
|
6
|
|
|
|
|
21
|
$self->opaque($opaque); |
29
|
|
|
|
|
|
|
} |
30
|
9
|
100
|
|
|
|
39
|
return uri_unescape($old) if $old; # media_type can't really be "0" |
31
|
3
|
|
|
|
|
8
|
"text/plain;charset=US-ASCII"; # default type |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub data |
35
|
|
|
|
|
|
|
{ |
36
|
17
|
|
|
17
|
1
|
388
|
my $self = shift; |
37
|
17
|
|
|
|
|
36
|
my($enc, $data) = split(",", $self->opaque, 2); |
38
|
17
|
100
|
|
|
|
42
|
unless (defined $data) { |
39
|
1
|
|
|
|
|
3
|
$data = ""; |
40
|
1
|
50
|
|
|
|
3
|
$enc = "" unless defined $enc; |
41
|
|
|
|
|
|
|
} |
42
|
17
|
|
|
|
|
40
|
my $base64 = ($enc =~ /;base64$/i); |
43
|
17
|
100
|
|
|
|
35
|
if (@_) { |
44
|
10
|
100
|
|
|
|
23
|
$enc =~ s/;base64$//i if $base64; |
45
|
10
|
|
|
|
|
59
|
my $new = shift; |
46
|
10
|
100
|
|
|
|
20
|
$new = "" unless defined $new; |
47
|
10
|
|
|
|
|
218
|
my $uric_count = _uric_count($new); |
48
|
10
|
|
|
|
|
22
|
my $urienc_len = $uric_count + (length($new) - $uric_count) * 3; |
49
|
10
|
|
|
|
|
28
|
my $base64_len = int((length($new)+2) / 3) * 4; |
50
|
10
|
|
|
|
|
13
|
$base64_len += 7; # because of ";base64" marker |
51
|
10
|
100
|
66
|
|
|
39
|
if ($base64_len < $urienc_len || $_[0]) { |
52
|
2
|
|
|
|
|
4
|
$enc .= ";base64"; |
53
|
2
|
|
|
|
|
15
|
$new = encode_base64($new, ""); |
54
|
|
|
|
|
|
|
} else { |
55
|
8
|
|
|
|
|
12
|
$new =~ s/%/%25/g; |
56
|
|
|
|
|
|
|
} |
57
|
10
|
|
|
|
|
70
|
$self->opaque("$enc,$new"); |
58
|
|
|
|
|
|
|
} |
59
|
17
|
100
|
|
|
|
38
|
return unless defined wantarray; |
60
|
9
|
|
|
|
|
20
|
$data = uri_unescape($data); |
61
|
9
|
100
|
|
|
|
60
|
return $base64 ? decode_base64($data) : $data; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# I could not find a better way to interpolate the tr/// chars from |
65
|
|
|
|
|
|
|
# a variable. |
66
|
|
|
|
|
|
|
my $ENC = $URI::uric; |
67
|
|
|
|
|
|
|
$ENC =~ s/%//; |
68
|
|
|
|
|
|
|
|
69
|
10
|
|
|
10
|
|
32
|
eval <
|
70
|
|
|
|
|
|
|
sub _uric_count |
71
|
|
|
|
|
|
|
{ |
72
|
|
|
|
|
|
|
\$_[0] =~ tr/$ENC//; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
EOT |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |