line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::URL; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
271876
|
use strict; |
|
6
|
|
|
|
|
47
|
|
|
6
|
|
|
|
|
176
|
|
4
|
6
|
|
|
6
|
|
40
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
187
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
2945
|
use parent 'URI::WithBase'; |
|
6
|
|
|
|
|
1854
|
|
|
6
|
|
|
|
|
31
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '5.19'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Provide as much as possible of the old URI::URL interface for backwards |
11
|
|
|
|
|
|
|
# compatibility... |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
368
|
use Exporter 5.57 'import'; |
|
6
|
|
|
|
|
95
|
|
|
6
|
|
|
|
|
405
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw(url); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Easy to use constructor |
17
|
7
|
|
|
7
|
0
|
228
|
sub url ($;$) { URI::URL->new(@_); } |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
6
|
|
36
|
use URI::Escape qw(uri_unescape); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
7672
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new |
22
|
|
|
|
|
|
|
{ |
23
|
255
|
|
|
255
|
1
|
57351
|
my $class = shift; |
24
|
255
|
|
|
|
|
833
|
my $self = $class->SUPER::new(@_); |
25
|
255
|
|
|
|
|
1050
|
$self->[0] = $self->[0]->canonical; |
26
|
255
|
|
|
|
|
834
|
$self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub newlocal |
30
|
|
|
|
|
|
|
{ |
31
|
6
|
|
|
6
|
0
|
184
|
my $class = shift; |
32
|
6
|
|
|
|
|
138
|
require URI::file; |
33
|
6
|
|
|
|
|
99
|
bless [URI::file->new_abs(shift)], $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
{package URI::_foreign; |
37
|
|
|
|
|
|
|
sub _init # hope it is not defined |
38
|
|
|
|
|
|
|
{ |
39
|
8
|
|
|
8
|
|
20
|
my $class = shift; |
40
|
8
|
50
|
|
|
|
20
|
die "Unknown URI::URL scheme $_[1]:" if $URI::URL::STRICT; |
41
|
8
|
|
|
|
|
40
|
$class->SUPER::_init(@_); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub strict |
46
|
|
|
|
|
|
|
{ |
47
|
2
|
|
|
2
|
0
|
1369
|
my $old = $URI::URL::STRICT; |
48
|
2
|
50
|
|
|
|
10
|
$URI::URL::STRICT = shift if @_; |
49
|
2
|
|
|
|
|
5
|
$old; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub print_on |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
55
|
0
|
|
|
|
|
0
|
require Data::Dumper; |
56
|
0
|
|
|
|
|
0
|
print STDERR Data::Dumper::Dumper($self); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _try |
60
|
|
|
|
|
|
|
{ |
61
|
42
|
|
|
42
|
|
59
|
my $self = shift; |
62
|
42
|
|
|
|
|
52
|
my $method = shift; |
63
|
42
|
|
|
|
|
52
|
scalar(eval { $self->$method(@_) }); |
|
42
|
|
|
|
|
127
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub crack |
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
# should be overridden by subclasses |
69
|
6
|
|
|
6
|
0
|
10
|
my $self = shift; |
70
|
6
|
|
|
|
|
33
|
(scalar($self->scheme), |
71
|
|
|
|
|
|
|
$self->_try("user"), |
72
|
|
|
|
|
|
|
$self->_try("password"), |
73
|
|
|
|
|
|
|
$self->_try("host"), |
74
|
|
|
|
|
|
|
$self->_try("port"), |
75
|
|
|
|
|
|
|
$self->_try("path"), |
76
|
|
|
|
|
|
|
$self->_try("params"), |
77
|
|
|
|
|
|
|
$self->_try("query"), |
78
|
|
|
|
|
|
|
scalar($self->fragment), |
79
|
|
|
|
|
|
|
) |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub full_path |
83
|
|
|
|
|
|
|
{ |
84
|
8
|
|
|
8
|
0
|
3407
|
my $self = shift; |
85
|
8
|
|
|
|
|
46
|
my $path = $self->path_query; |
86
|
8
|
50
|
|
|
|
30
|
$path = "/" unless length $path; |
87
|
8
|
|
|
|
|
47
|
$path; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub netloc |
91
|
|
|
|
|
|
|
{ |
92
|
16
|
|
|
16
|
0
|
1511
|
shift->authority(@_); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub epath |
96
|
|
|
|
|
|
|
{ |
97
|
33
|
|
|
33
|
0
|
875
|
my $path = shift->SUPER::path(@_); |
98
|
33
|
|
|
|
|
83
|
$path =~ s/;.*//; |
99
|
33
|
|
|
|
|
65
|
$path; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub eparams |
103
|
|
|
|
|
|
|
{ |
104
|
12
|
|
|
12
|
0
|
540
|
my $self = shift; |
105
|
12
|
|
|
|
|
59
|
my @p = $self->path_segments; |
106
|
11
|
100
|
|
|
|
54
|
return undef unless ref($p[-1]); |
107
|
3
|
|
|
|
|
36
|
@p = @{$p[-1]}; |
|
3
|
|
|
|
|
35
|
|
108
|
3
|
|
|
|
|
10
|
shift @p; |
109
|
3
|
|
|
|
|
17
|
join(";", @p); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
10
|
|
|
10
|
0
|
2808
|
sub params { shift->eparams(@_); } |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub path { |
115
|
28
|
|
|
28
|
0
|
7537
|
my $self = shift; |
116
|
28
|
|
|
|
|
77
|
my $old = $self->epath(@_); |
117
|
28
|
100
|
|
|
|
73
|
return unless defined wantarray; |
118
|
23
|
50
|
33
|
|
|
108
|
return '/' if !defined($old) || !length($old); |
119
|
23
|
100
|
66
|
|
|
327
|
Carp::croak("Path components contain '/' (you must call epath)") |
120
|
|
|
|
|
|
|
if $old =~ /%2[fF]/ and !@_; |
121
|
22
|
100
|
100
|
|
|
96
|
$old = "/$old" if $old !~ m|^/| && defined $self->netloc; |
122
|
22
|
|
|
|
|
62
|
return uri_unescape($old); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub path_components { |
126
|
4
|
|
|
4
|
0
|
32
|
shift->path_segments(@_); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub query { |
130
|
18
|
|
|
18
|
0
|
5174
|
my $self = shift; |
131
|
18
|
|
|
|
|
91
|
my $old = $self->equery(@_); |
132
|
18
|
100
|
100
|
|
|
96
|
if (defined(wantarray) && defined($old)) { |
133
|
7
|
100
|
|
|
|
32
|
if ($old =~ /%(?:26|2[bB]|3[dD])/) { # contains escaped '=' '&' or '+' |
134
|
1
|
|
|
|
|
4
|
my $mess; |
135
|
1
|
|
|
|
|
4
|
for ($old) { |
136
|
1
|
50
|
33
|
|
|
5
|
$mess = "Query contains both '+' and '%2B'" |
137
|
|
|
|
|
|
|
if /\+/ && /%2[bB]/; |
138
|
1
|
50
|
33
|
|
|
10
|
$mess = "Form query contains escaped '=' or '&'" |
139
|
|
|
|
|
|
|
if /=/ && /%(?:3[dD]|26)/; |
140
|
|
|
|
|
|
|
} |
141
|
1
|
50
|
|
|
|
4
|
if ($mess) { |
142
|
1
|
|
|
|
|
76
|
Carp::croak("$mess (you must call equery)"); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
# Now it should be safe to unescape the string without losing |
146
|
|
|
|
|
|
|
# information |
147
|
6
|
|
|
|
|
21
|
return uri_unescape($old); |
148
|
|
|
|
|
|
|
} |
149
|
11
|
|
|
|
|
44
|
undef; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub abs |
154
|
|
|
|
|
|
|
{ |
155
|
80
|
|
|
80
|
1
|
255
|
my $self = shift; |
156
|
80
|
|
|
|
|
112
|
my $base = shift; |
157
|
80
|
|
|
|
|
107
|
my $allow_scheme = shift; |
158
|
80
|
100
|
|
|
|
177
|
$allow_scheme = $URI::URL::ABS_ALLOW_RELATIVE_SCHEME |
159
|
|
|
|
|
|
|
unless defined $allow_scheme; |
160
|
80
|
|
|
|
|
122
|
local $URI::ABS_ALLOW_RELATIVE_SCHEME = $allow_scheme; |
161
|
80
|
|
|
|
|
125
|
local $URI::ABS_REMOTE_LEADING_DOTS = $URI::URL::ABS_REMOTE_LEADING_DOTS; |
162
|
80
|
|
|
|
|
242
|
$self->SUPER::abs($base); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
7
|
|
|
7
|
0
|
2067
|
sub frag { shift->fragment(@_); } |
166
|
5
|
|
|
5
|
0
|
33
|
sub keywords { shift->query_keywords(@_); } |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# file: |
169
|
1
|
|
|
1
|
0
|
46
|
sub local_path { shift->file; } |
170
|
9
|
|
|
9
|
0
|
101
|
sub unix_path { shift->file("unix"); } |
171
|
2
|
|
|
2
|
0
|
54
|
sub dos_path { shift->file("dos"); } |
172
|
3
|
|
|
3
|
0
|
34
|
sub mac_path { shift->file("mac"); } |
173
|
0
|
|
|
0
|
0
|
0
|
sub vms_path { shift->file("vms"); } |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# mailto: |
176
|
1
|
|
|
1
|
0
|
20
|
sub address { shift->to(@_); } |
177
|
1
|
|
|
1
|
0
|
759
|
sub encoded822addr { shift->to(@_); } |
178
|
1
|
|
|
1
|
1
|
10
|
sub URI::mailto::authority { shift->to(@_); } # make 'netloc' method work |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# news: |
181
|
1
|
|
|
1
|
0
|
20
|
sub groupart { shift->_group(@_); } |
182
|
3
|
|
|
3
|
0
|
31
|
sub article { shift->message(@_); } |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
__END__ |