| 1 | package URI::file::Base; | ||||||||||||||||||||||||||||||
| 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 URI::Escape (); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||
| 8 | 4 | our $VERSION = '5.40'; | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||
| 10 | 69 | ▶ | sub new { | ||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.2
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 11 | 69 | my $class = shift; | |||||||||||||||||||||||||||||
| 12 | 69 | my $path = shift; | |||||||||||||||||||||||||||||
| 13 | 69 | ▶ | $path = "" unless defined $path; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||
| 15 | 69 | my ($auth, $escaped_auth, $escaped_path); | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||
| 17 | 69 | ($auth, $escaped_auth) = $class->_file_extract_authority($path); | |||||||||||||||||||||||||||||
| 18 | 69 | ($path, $escaped_path) = $class->_file_extract_path($path); | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||
| 20 | 69 | ▶ | if (defined $auth) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 21 | 18 | ▶ | $auth =~ s,%,%25,g unless $escaped_auth; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 22 | 0 | $auth =~ s,([/?\#\t\n\f\r\x0b ]), URI::Escape::escape_char($1),eg; | |||||||||||||||||||||||||||||
| 23 | 18 | $auth = "//$auth"; | |||||||||||||||||||||||||||||
| 24 | 18 | ▶ | if (defined $path) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 25 | 18 | ▶ | $path = "/$path" unless substr($path, 0, 1) eq "/"; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||
| 27 | else { | ||||||||||||||||||||||||||||||
| 28 | 0 | $path = ""; | |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||||
| 32 | 51 | ▶ | return undef unless defined $path; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 33 | 51 | $auth = ""; | |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||
| 36 | 69 | ▶ | $path =~ s,([%;?\t\n\f\r\x0b ]), URI::Escape::escape_char($1),eg | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 37 | unless $escaped_path; | ||||||||||||||||||||||||||||||
| 38 | 69 | $path =~ s/\#/%23/g; | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||
| 40 | 69 | my $uri = $auth . $path; | |||||||||||||||||||||||||||||
| 41 | 69 | ▶ | $uri = "file:$uri" if substr($uri, 0, 1) eq "/"; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||
| 43 | 69 | URI->new($uri, "file"); | |||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||
| 46 | 62 | ▶ | sub _file_extract_authority { | ||||||||||||||||||||||||||||
|
Subroutine
_file_extract_authority: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 47 | 62 | my ($class, $path) = @_; | |||||||||||||||||||||||||||||
| 48 | 62 | ▶ | return undef unless $class->_file_is_absolute($path); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 49 | 24 | return $URI::file::DEFAULT_AUTHORITY; | |||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub _file_extract_path { | ||||||||||||||||||||||||||||
|
Subroutine
_file_extract_path: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 53 | 0 | return undef; | |||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||
| 56 | 18 | ▶ | sub _file_is_absolute { | ||||||||||||||||||||||||||||
|
Subroutine
_file_is_absolute: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 57 | 18 | return 0; | |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||
| 60 | 10 | ▶ | sub _file_is_localhost { | ||||||||||||||||||||||||||||
|
Subroutine
_file_is_localhost: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||
| 61 | 10 | shift; # class | |||||||||||||||||||||||||||||
| 62 | 10 | my $host = lc(shift); | |||||||||||||||||||||||||||||
| 63 | 10 | ▶ | return 1 if $host eq "localhost"; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 64 | 10 | eval { | |||||||||||||||||||||||||||||
| 65 | 10 | require Net::Domain; | |||||||||||||||||||||||||||||
| 66 | 10 | ▶ | lc(Net::Domain::hostfqdn() || '') eq $host | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
Net::Domain::hostfqdn() || ''
Net::Domain::hostname() || ''
MC/DC0%0/1
Net::Domain::hostfqdn() || ''
Net::Domain::hostfqdn()
MC/DC0%0/1
Net::Domain::hostname() || ''
Net::Domain::hostname()
Truth table50%1/2
A
A= Net::Domain::hostfqdn()
Truth table50%1/2
A
A= Net::Domain::hostname()
| |||||||||||||||||||||||||||||||
| 67 | || lc(Net::Domain::hostname() || '') eq $host; | ||||||||||||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub file { | ||||||||||||||||||||||||||||
|
Subroutine
file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 72 | 0 | undef; | |||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub dir { | ||||||||||||||||||||||||||||
|
Subroutine
dir: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 77 | 0 | $self->file(@_); | |||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||
| 80 | 4 | 1; | |||||||||||||||||||||||||||||