line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::file::Base; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
1923
|
use strict; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
151
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
128
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
33
|
use URI::Escape (); |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
2503
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '5.19'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
51
|
|
|
51
|
0
|
141
|
my $class = shift; |
13
|
51
|
|
|
|
|
144
|
my $path = shift; |
14
|
51
|
100
|
|
|
|
180
|
$path = "" unless defined $path; |
15
|
|
|
|
|
|
|
|
16
|
51
|
|
|
|
|
96
|
my($auth, $escaped_auth, $escaped_path); |
17
|
|
|
|
|
|
|
|
18
|
51
|
|
|
|
|
244
|
($auth, $escaped_auth) = $class->_file_extract_authority($path); |
19
|
51
|
|
|
|
|
209
|
($path, $escaped_path) = $class->_file_extract_path($path); |
20
|
|
|
|
|
|
|
|
21
|
51
|
100
|
|
|
|
125
|
if (defined $auth) { |
22
|
12
|
50
|
|
|
|
33
|
$auth =~ s,%,%25,g unless $escaped_auth; |
23
|
12
|
|
|
|
|
15
|
$auth =~ s,([/?\#]), URI::Escape::escape_char($1),eg; |
|
0
|
|
|
|
|
0
|
|
24
|
12
|
|
|
|
|
23
|
$auth = "//$auth"; |
25
|
12
|
50
|
|
|
|
35
|
if (defined $path) { |
26
|
12
|
100
|
|
|
|
47
|
$path = "/$path" unless substr($path, 0, 1) eq "/"; |
27
|
|
|
|
|
|
|
} else { |
28
|
0
|
|
|
|
|
0
|
$path = ""; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} else { |
31
|
39
|
50
|
|
|
|
124
|
return undef unless defined $path; |
32
|
39
|
|
|
|
|
139
|
$auth = ""; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
51
|
100
|
|
|
|
202
|
$path =~ s,([%;?]), URI::Escape::escape_char($1),eg unless $escaped_path; |
|
0
|
|
|
|
|
0
|
|
36
|
51
|
|
|
|
|
108
|
$path =~ s/\#/%23/g; |
37
|
|
|
|
|
|
|
|
38
|
51
|
|
|
|
|
149
|
my $uri = $auth . $path; |
39
|
51
|
100
|
|
|
|
235
|
$uri = "file:$uri" if substr($uri, 0, 1) eq "/"; |
40
|
|
|
|
|
|
|
|
41
|
51
|
|
|
|
|
441
|
URI->new($uri, "file"); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _file_extract_authority |
45
|
|
|
|
|
|
|
{ |
46
|
44
|
|
|
44
|
|
187
|
my($class, $path) = @_; |
47
|
44
|
100
|
|
|
|
226
|
return undef unless $class->_file_is_absolute($path); |
48
|
18
|
|
|
|
|
78
|
return $URI::file::DEFAULT_AUTHORITY; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _file_extract_path |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
|
0
|
return undef; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _file_is_absolute |
57
|
|
|
|
|
|
|
{ |
58
|
12
|
|
|
12
|
|
37
|
return 0; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _file_is_localhost |
62
|
|
|
|
|
|
|
{ |
63
|
10
|
|
|
10
|
|
19
|
shift; # class |
64
|
10
|
|
|
|
|
17
|
my $host = lc(shift); |
65
|
10
|
50
|
|
|
|
21
|
return 1 if $host eq "localhost"; |
66
|
10
|
|
|
|
|
14
|
eval { |
67
|
10
|
|
|
|
|
1100
|
require Net::Domain; |
68
|
10
|
50
|
50
|
|
|
18336
|
lc(Net::Domain::hostfqdn() || '') eq $host || |
|
|
|
50
|
|
|
|
|
69
|
|
|
|
|
|
|
lc(Net::Domain::hostname() || '') eq $host; |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub file |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
0
|
0
|
|
undef; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub dir |
79
|
|
|
|
|
|
|
{ |
80
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
81
|
0
|
|
|
|
|
|
$self->file(@_); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |