URI/file/Unix.pm

filter: Statementstmt 100% 37 / 37 Branchbran 71.4% 10 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 92.1% 59 / 64 CC 10 SCAR 17.3
CC
10
Cov
93%
file
9.1
_file_extract_path
2.0
BEGIN
1.0
CRAP 5.7
« URI.pm ↑ Summary URI/Escape.pm »
1 package URI::file::Unix;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use parent 'URI::file::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use URI::Escape qw(uri_unescape);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = '5.40';
11  
12 38 ▶sub _file_extract_path {
Subroutine _file_extract_path: called CC=2 SCAR=7.0
13 38 my ($class, $path) = @_;
14  
15 # tidy path
16 38 $path =~ s,//+,/,g;
17 38 $path =~ s,(/\.)+/,/,g;
18 38 ▶ $path = "./$path" if $path =~ m,^[^:/]+:,,; # look like "scheme:"
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[^[^:/]+:] 0 38 38
19  
20 38 return $path;
21 }
22  
23 38 ▶sub _file_is_absolute {
Subroutine _file_is_absolute: called CC=1 SCAR=0.0
24 38 my ($class, $path) = @_;
25 38 return $path =~ m,^/,;
26 }
27  
28 42 ▶sub file {
Subroutine file: called CC=9 SCAR=22.1
Pod undocumented
29 42 my $class = shift;
30 42 my $uri = shift;
31 42 my @path;
32  
33 42 my $auth = $uri->authority;
34 42 ▶ if (defined($auth)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $auth) 19 23 42
35 19 ▶ if (lc($auth) ne "localhost" && $auth ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $auth ne "localhost" and $auth ne "") 5 14 19
Condition100%3/3
lc $auth ne "localhost" and $auth ne ""
!ll&&!rl&&r
2125
MC/DC100%2/2
lc $auth ne "localhost" and $auth ne ""
lc $auth ne "localhost" $auth ne ""
Truth table100%3/3
A and B
A= lc $auth ne "localhost"B= $auth ne ""
ABresult
0X0
100
111
36 5 $auth = uri_unescape($auth);
37 5 ▶ unless ($class->_file_is_localhost($auth)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->_file_is_localhost($auth)) 5 0 5
38 5 push(@path, "", "", $auth);
39 }
40 }
41 }
42  
43 42 my @ps = $uri->path_segments;
44 42 ▶ shift @ps if @path;
Branch: 1 branch
BranchTrueFalseTotal
if @path 5 37 42
45 42 push(@path, @ps);
46  
47 42 for (@path) {
48  
49 # Unix file/directory names are not allowed to contain '\0' or '/'
50 141 ▶ return undef if /\0/;
Branch: 1 branch
BranchTrueFalseTotal
if /\0/ 0 141 141
51 141 ▶ return undef if /\//; # should we really?
Branch: 1 branch
BranchTrueFalseTotal
if m[/] 0 141 141
52 }
53  
54 42 return join("/", @path);
55 }
56  
57 4 1;
« URI.pm ↑ Summary URI/Escape.pm »