line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::file::Win32; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
552
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
106
|
|
4
|
3
|
|
|
3
|
|
28
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
92
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
16
|
use parent 'URI::file::Base'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
30
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
238
|
use URI::Escape qw(uri_unescape); |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
2651
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '5.19'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _file_extract_authority |
13
|
|
|
|
|
|
|
{ |
14
|
13
|
|
|
13
|
|
18
|
my $class = shift; |
15
|
|
|
|
|
|
|
|
16
|
13
|
100
|
|
|
|
40
|
return $class->SUPER::_file_extract_authority($_[0]) |
17
|
|
|
|
|
|
|
if defined $URI::file::DEFAULT_AUTHORITY; |
18
|
|
|
|
|
|
|
|
19
|
7
|
100
|
|
|
|
19
|
return $1 if $_[0] =~ s,^\\\\([^\\]+),,; # UNC |
20
|
6
|
50
|
|
|
|
13
|
return $1 if $_[0] =~ s,^//([^/]+),,; # UNC too? |
21
|
|
|
|
|
|
|
|
22
|
6
|
100
|
|
|
|
16
|
if ($_[0] =~ s,^([a-zA-Z]:),,) { |
23
|
1
|
|
|
|
|
2
|
my $auth = $1; |
24
|
1
|
50
|
|
|
|
5
|
$auth .= "relative" if $_[0] !~ m,^[\\/],; |
25
|
1
|
|
|
|
|
3
|
return $auth; |
26
|
|
|
|
|
|
|
} |
27
|
5
|
|
|
|
|
11
|
return undef; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _file_extract_path |
31
|
|
|
|
|
|
|
{ |
32
|
13
|
|
|
13
|
|
24
|
my($class, $path) = @_; |
33
|
13
|
|
|
|
|
35
|
$path =~ s,\\,/,g; |
34
|
|
|
|
|
|
|
#$path =~ s,//+,/,g; |
35
|
13
|
|
|
|
|
23
|
$path =~ s,(/\.)+/,/,g; |
36
|
|
|
|
|
|
|
|
37
|
13
|
100
|
|
|
|
27
|
if (defined $URI::file::DEFAULT_AUTHORITY) { |
38
|
6
|
|
|
|
|
13
|
$path =~ s,^([a-zA-Z]:),/$1,; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
13
|
|
|
|
|
30
|
return $path; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _file_is_absolute { |
45
|
6
|
|
|
6
|
|
12
|
my($class, $path) = @_; |
46
|
6
|
|
100
|
|
|
53
|
return $path =~ m,^[a-zA-Z]:, || $path =~ m,^[/\\],; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub file |
50
|
|
|
|
|
|
|
{ |
51
|
26
|
|
|
26
|
0
|
43
|
my $class = shift; |
52
|
26
|
|
|
|
|
46
|
my $uri = shift; |
53
|
26
|
|
|
|
|
72
|
my $auth = $uri->authority; |
54
|
26
|
|
|
|
|
39
|
my $rel; # is filename relative to drive specified in authority |
55
|
26
|
100
|
|
|
|
58
|
if (defined $auth) { |
56
|
11
|
|
|
|
|
31
|
$auth = uri_unescape($auth); |
57
|
11
|
100
|
|
|
|
55
|
if ($auth =~ /^([a-zA-Z])[:|](relative)?/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
58
|
3
|
|
|
|
|
15
|
$auth = uc($1) . ":"; |
59
|
3
|
100
|
|
|
|
14
|
$rel++ if $2; |
60
|
|
|
|
|
|
|
} elsif (lc($auth) eq "localhost") { |
61
|
2
|
|
|
|
|
4
|
$auth = ""; |
62
|
|
|
|
|
|
|
} elsif (length $auth) { |
63
|
2
|
|
|
|
|
8
|
$auth = "\\\\" . $auth; # UNC |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} else { |
66
|
15
|
|
|
|
|
22
|
$auth = ""; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
26
|
|
|
|
|
70
|
my @path = $uri->path_segments; |
70
|
26
|
|
|
|
|
61
|
for (@path) { |
71
|
55
|
50
|
|
|
|
107
|
return undef if /\0/; |
72
|
55
|
50
|
|
|
|
110
|
return undef if /\//; |
73
|
|
|
|
|
|
|
#return undef if /\\/; # URLs with "\" is not uncommon |
74
|
|
|
|
|
|
|
} |
75
|
26
|
50
|
|
|
|
61
|
return undef unless $class->fix_path(@path); |
76
|
|
|
|
|
|
|
|
77
|
26
|
|
|
|
|
60
|
my $path = join("\\", @path); |
78
|
26
|
100
|
|
|
|
54
|
$path =~ s/^\\// if $rel; |
79
|
26
|
|
|
|
|
50
|
$path = $auth . $path; |
80
|
26
|
|
|
|
|
79
|
$path =~ s,^\\([a-zA-Z])[:|],\u$1:,; |
81
|
|
|
|
|
|
|
|
82
|
26
|
|
|
|
|
93
|
return $path; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
24
|
|
|
24
|
0
|
52
|
sub fix_path { 1; } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |