| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 35 | 19 | ▶ | if (lc($auth) ne "localhost" && $auth ne "") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
lc $auth ne "localhost" and $auth ne ""
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 ""
| |||||||||||||||||||||||||||||
| 36 | 5 | $auth = uri_unescape($auth); | |||||||||||||||||||||||||||
| 37 | 5 | ▶ | unless ($class->_file_is_localhost($auth)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 51 | 141 | ▶ | return undef if /\//; # should we really? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 42 | return join("/", @path); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 4 | 1; | |||||||||||||||||||||||||||