| 1 | package Net::Blossom::_URL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strictures 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use URI (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 51 | ▶ | sub http_base_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http_base_url: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 51 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 51 | return _http_url($value, allow_path => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | sub http_root_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http_root_url: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | return _http_url($value, allow_path => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 58 | ▶ | sub _http_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_http_url: called CC=18 SCAR=29.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 58 | my ($value, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 58 | ▶ | return 0 unless defined $value && !ref($value) && length $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $value and not ref $value and length $value
defined $value and not ref $value
MC/DC33%1/3
defined $value and not ref $value and length $value
defined $value
not ref $value
length $value
Truth table50%2/4
A and not(B) and C
A= defined $valueB= not ref $valueC= length $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 57 | ▶ | return 0 if $value =~ /[\x00-\x20]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 56 | my $uri = URI->new($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 56 | my $scheme = $uri->scheme; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 56 | ▶ | return 0 unless defined $scheme && $scheme =~ /\Ahttps?\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $scheme and $scheme =~ /\Ahttps?\z/i
MC/DC100%2/2
defined $scheme and $scheme =~ /\Ahttps?\z/i
defined $scheme
$scheme =~ /\Ahttps?\z/i
Truth table100%3/3
A and B
A= defined $schemeB= $scheme =~ /\Ahttps?\z/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 54 | my $authority = eval { $uri->authority }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 54 | ▶ | return 0 unless _valid_http_authority($authority); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 48 | my $host = eval { $uri->host }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 48 | ▶ | return 0 unless defined $host && length $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $host and length $host
MC/DC0%0/2
defined $host and length $host
defined $host
length $host
Truth table33%1/3
A and B
A= defined $hostB= length $host
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 48 | my $userinfo = eval { $uri->userinfo }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 48 | ▶ | return 0 if defined $userinfo && length $userinfo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $userinfo and length $userinfo
MC/DC0%0/2
defined $userinfo and length $userinfo
defined $userinfo
length $userinfo
Truth table33%1/3
A and B
A= defined $userinfoB= length $userinfo
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 48 | ▶ | return 0 if defined $uri->query; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 46 | ▶ | return 0 if defined $uri->fragment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 45 | my $path = $uri->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 45 | ▶ | return 0 if !$opts{allow_path} && defined($path) && length($path) && $path ne '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
not $opts{"allow_path"} and defined $path and length $path and $path ne "/"
not $opts{"allow_path"} and defined $path and length $path
not $opts{"allow_path"} and defined $path
MC/DC75%3/4
not $opts{"allow_path"} and defined $path and length $path and $path ne "/"
not $opts{"allow_path"}
defined $path
length $path
$path ne "/"
Truth table80%4/5
not(A) and B and C and D
A= not $opts{"allow_path"}B= defined $pathC= length $pathD= $path ne "/"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 43 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 54 | ▶ | sub _valid_http_authority { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_http_authority: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 54 | my ($authority) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 54 | ▶ | return 0 unless defined $authority && length $authority; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $authority and length $authority
MC/DC50%1/2
defined $authority and length $authority
defined $authority
length $authority
Truth table66%2/3
A and B
A= defined $authorityB= length $authority
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 53 | ▶ | return 0 if $authority =~ /\@/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 52 | my $port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 52 | ▶ | if ($authority =~ /\A\[[0-9A-Fa-f:.]+\](?::([0-9]+))?\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | $port = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | elsif ($authority =~ /\A([^:]+)(?::([0-9]+))?\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 49 | ▶ | return 0 if $1 =~ /[\[\]]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 49 | $port = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 50 | ▶ | return 0 if defined $port && ($port < 1 || $port > 65535); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $port and $port < 1 || $port > 65535
$port < 1 or $port > 65535
MC/DC100%3/3
defined $port and $port < 1 || $port > 65535
defined $port
$port < 1
$port > 65535
Truth table100%4/4
A and B or C
A= defined $portB= $port < 1C= $port > 65535
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 48 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||