| 1 | package OpenID::Lite::Realm; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Any::Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use List::MoreUtils qw(any none); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use OpenID::Lite::Provider::Discover; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use OpenID::Lite::Util::URI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | has 'origin' => ( | |||||||||||||||||||||||||||||||||||||||||
| 11 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 12 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | has 'scheme' => ( | |||||||||||||||||||||||||||||||||||||||||
| 17 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 18 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | has 'host' => ( | |||||||||||||||||||||||||||||||||||||||||
| 23 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | default => '', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | has 'port' => ( | |||||||||||||||||||||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | has 'path' => ( | |||||||||||||||||||||||||||||||||||||||||
| 34 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | default => '/', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | has 'has_wildcard' => ( | |||||||||||||||||||||||||||||||||||||||||
| 40 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | my @TLDs = qw( | |||||||||||||||||||||||||||||||||||||||||
| 46 | ac ad ae aero af ag ai al am an ao aq ar arpa as asia at | ||||||||||||||||||||||||||||||||||||||||||
| 47 | au aw ax az ba bb bd be bf bg bh bi biz bj bm bn bo br bs bt | ||||||||||||||||||||||||||||||||||||||||||
| 48 | bv bw by bz ca cat cc cd cf cg ch ci ck cl cm cn co com coop | ||||||||||||||||||||||||||||||||||||||||||
| 49 | cr cu cv cx cy cz de dj dk dm do dz ec edu ee eg er es et eu | ||||||||||||||||||||||||||||||||||||||||||
| 50 | fi fj fk fm fo fr ga gb gd ge gf gg gh gi gl gm gn gov gp gq | ||||||||||||||||||||||||||||||||||||||||||
| 51 | gr gs gt gu gw gy hk hm hn hr ht hu id ie il im in info int | ||||||||||||||||||||||||||||||||||||||||||
| 52 | io iq ir is it je jm jo jobs jp ke kg kh ki km kn kp kr kw | ||||||||||||||||||||||||||||||||||||||||||
| 53 | ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mg mh mil | ||||||||||||||||||||||||||||||||||||||||||
| 54 | mk ml mm mn mo mobi mp mq mr ms mt mu museum mv mw mx my mz | ||||||||||||||||||||||||||||||||||||||||||
| 55 | na name nc ne net nf ng ni nl no np nr nu nz om org pa pe pf | ||||||||||||||||||||||||||||||||||||||||||
| 56 | pg ph pk pl pm pn pr pro ps pt pw py qa re ro rs ru rw sa sb | ||||||||||||||||||||||||||||||||||||||||||
| 57 | sc sd se sg sh si sj sk sl sm sn so sr st su sv sy sz tc td | ||||||||||||||||||||||||||||||||||||||||||
| 58 | tel tf tg th tj tk tl tm tn to tp tr travel tt tv tw tz ua | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ug uk us uy uz va vc ve vg vi vn vu wf ws xn--0zwm56d | ||||||||||||||||||||||||||||||||||||||||||
| 60 | xn--11b5bs3a9aj6g xn--80akhbyknj4f xn--9t4b11yi5a | ||||||||||||||||||||||||||||||||||||||||||
| 61 | xn--deba0ad xn--g6w251d xn--hgbk6aj7f53bba | ||||||||||||||||||||||||||||||||||||||||||
| 62 | xn--hlcj6aya9esc7a xn--jxalpdlp xn--kgbechtv xn--zckzah ye | ||||||||||||||||||||||||||||||||||||||||||
| 63 | yt yu za zm zw | ||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 11 | ▶ | sub return_to_matches { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
return_to_matches: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 11 | my ( $class, $urls, $return_to ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 11 | ▶ | $return_to ||= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$return_to ||= ""
MC/DC100%1/1
$return_to ||= ""
$return_to
Truth table100%2/2
A
A= $return_to
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 11 | for my $url (@$urls) { | |||||||||||||||||||||||||||||||||||||||||
| 70 | 10 | my $r = $class->parse($url); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 10 | ▶ | return 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$r and not $r->has_wildcard and $r->validate_url($return_to)
$r and not $r->has_wildcard
MC/DC100%3/3
$r and not $r->has_wildcard and $r->validate_url($return_to)
$r
not $r->has_wildcard
$r->validate_url($return_to)
Truth table100%4/4
A and not(B) and C
A= $rB= not $r->has_wildcardC= $r->validate_url($return_to)
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | if ( $r | ||||||||||||||||||||||||||||||||||||||||||
| 73 | && !$r->has_wildcard | ||||||||||||||||||||||||||||||||||||||||||
| 74 | && $r->validate_url($return_to) ); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 9 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub get_allowed_return_urls { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_allowed_return_urls: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my ( $self, $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $disco = OpenID::Lite::Provider::Discover->new(); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my $urls = $disco->discover($url, 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | or return; | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub verify_return_to { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_return_to: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ( $class, $realm, $return_to ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $r = $class->parse($realm); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | return unless $r; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $disco_url = $r->build_discovery_url(); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $allowable_urls = $class->get_allowed_return_urls($disco_url); | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ( $class->return_to_matches( $allowable_urls, $return_to ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 93 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 93 | my ( $class, $realm ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 93 | my $origin = $realm; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 93 | ▶ | my $found_wildcard = ( index( $realm, q{://*.} ) >= 0 ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 93 | ▶ | $realm =~ s/\*\.// if $found_wildcard; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 93 | ▶ | if ( !$found_wildcard && $realm =~ m|^https?\://\*/$| ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $found_wildcard and $realm =~ m[^https?\://\*/$]
MC/DC100%2/2
not $found_wildcard and $realm =~ m[^https?\://\*/$]
not $found_wildcard
$realm =~ m[^https?\://\*/$]
Truth table100%3/3
not(A) and B
A= not $found_wildcardB= $realm =~ m[^https?\://\*/$]
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 4 | my $scheme = ( split( /\:/, $realm ) )[0]; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | ▶ | my $port = $scheme eq 'http' ? 80 : 443; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | return $class->new( | |||||||||||||||||||||||||||||||||||||||||
| 107 | origin => $origin, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | scheme => $scheme, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | host => '', | ||||||||||||||||||||||||||||||||||||||||||
| 110 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | has_wildcard => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | path => '/', | ||||||||||||||||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 89 | my $parts = $class->_parse($realm); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 89 | ▶ | return unless $parts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 71 | my ( $scheme, $host, $port, $path ) = @$parts; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 71 | ▶ | if ( $path && index( $path, q{#} ) >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$path and index($path, "#") != -1
MC/DC50%1/2
$path and index($path, "#") != -1
$path
index($path, "#") != -1
Truth table66%2/3
A and B
A= $pathB= index($path, "#") != -1
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 70 | ▶ | return if ( none { $_ eq $scheme } qw(http https) ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 70 | return $class->new( | |||||||||||||||||||||||||||||||||||||||||
| 123 | origin => $origin, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | scheme => $scheme, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 128 | has_wildcard => $found_wildcard, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 96 | ▶ | sub _parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 96 | my ( $class, $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 96 | ▶ | $url = OpenID::Lite::Util::URI->normalize($url) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | or return; | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 88 | ▶ | return unless OpenID::Lite::Util::URI->is_uri($url); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 77 | my $u = URI->new($url); | |||||||||||||||||||||||||||||||||||||||||
| 138 | 77 | my $path = $u->path; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 77 | ▶ | $path .= sprintf q{?%s}, $u->query if $u->query; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 77 | ▶ | $path .= sprintf q{#%s}, $u->fragment if $u->fragment; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 77 | ▶ | return [ $u->scheme || '', $u->host || '', $u->port || '', $path ]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$u->scheme || ''
$u->host || ''
$u->port || ''
MC/DC0%0/1
$u->scheme || ''
$u->scheme
MC/DC0%0/1
$u->host || ''
$u->host
MC/DC0%0/1
$u->port || ''
$u->port
Truth table50%1/2
A
A= $u->scheme
Truth table50%1/2
A
A= $u->host
Truth table50%1/2
A
A= $u->port
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub check_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_url: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my ( $class, $realm, $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $r = $class->parse($realm); | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | return ( $r && $r->validate_url($url) ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$r and $r->validate_url($url)
MC/DC0%0/2
$r and $r->validate_url($url)
$r
$r->validate_url($url)
Truth table0%0/3
A and B
A= $rB= $r->validate_url($url)
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 31 | ▶ | sub check_sanity { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_sanity: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 31 | my ( $class, $realm ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 31 | my $r = $class->parse($realm); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 31 | ▶ | return ( $r && $r->is_sane() ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$r and $r->is_sane
MC/DC50%1/2
$r and $r->is_sane
$r
$r->is_sane
Truth table66%2/3
A and B
A= $rB= $r->is_sane
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | ▶ | sub build_discovery_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_discovery_url: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | ▶ | if ( $self->has_wildcard ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | my $port | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->port and $self->port != 80 and $self->port != 443
$self->port and $self->port != 80
MC/DC33%1/3
$self->port and $self->port != 80 and $self->port != 443
$self->port
$self->port != 80
$self->port != 443
Truth table50%2/4
A and B and C
A= $self->portB= $self->port != 80C= $self->port != 443
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | = ( $self->port && $self->port != 80 && $self->port != 443 ) | ||||||||||||||||||||||||||||||||||||||||||
| 161 | ? sprintf(":%d", $self->port) | ||||||||||||||||||||||||||||||||||||||||||
| 162 | : ''; | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | return sprintf q{%s://www.%s%s%s}, | |||||||||||||||||||||||||||||||||||||||||
| 164 | $self->scheme, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | $self->host, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | $port, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | $self->path; | ||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | return $self->origin; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 62 | ▶ | sub is_sane { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_sane: called CC=10 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 62 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 62 | ▶ | return 1 if $self->host eq 'localhost'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 58 | my @host_parts = split( /\./, $self->host ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 58 | ▶ | return 0 if scalar(@host_parts) == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 54 | ▶ | return 0 if ( any { $_ eq '' } @host_parts ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 54 | my $tld = $host_parts[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 54 | ▶ | return 0 if ( none { $tld eq $_ } @TLDs ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 48 | ▶ | return 0 if scalar(@host_parts) == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 36 | ▶ | if ( $self->has_wildcard ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 18 | ▶ | if ( length($tld) == 2 && length( $host_parts[-2] ) <= 3 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $tld == 2 and length $host_parts[-2] <= 3
MC/DC50%1/2
length $tld == 2 and length $host_parts[-2] <= 3
length $tld == 2
length $host_parts[-2] <= 3
Truth table66%2/3
A and B
A= length $tld == 2B= length $host_parts[-2] <= 3
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 4 | ▶ | return @host_parts > 2 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 32 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 7 | ▶ | sub validate_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_url: called CC=15 SCAR=32.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | my ( $self, $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 7 | ▶ | my $parts = ref($self)->_parse($url) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | or return 0; | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 6 | my ( $scheme, $host, $port, $path ) = @$parts; | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | ▶ | return 0 unless $self->scheme eq $scheme; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | ▶ | return 0 unless $self->port == $port; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | ▶ | return 0 if ( index( $host, q{*} ) >= 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | my $s_host = $self->host; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 6 | ▶ | if ( !$self->has_wildcard ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 6 | ▶ | return 0 if $s_host ne $host; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | ▶ | elsif ($s_host ne '' | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$s_host ne "" and not $host =~ /\.$s_host$/ and $host ne $s_host
$s_host ne "" and not $host =~ /\.$s_host$/
MC/DC0%0/3
$s_host ne "" and not $host =~ /\.$s_host$/ and $host ne $s_host
$s_host ne ""
not $host =~ /\.$s_host$/
$host ne $s_host
Truth table0%0/4
A and not(B) and C
A= $s_host ne ""B= not $host =~ /\.$s_host$/C= $host ne $s_host
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | && $host !~ /\.$s_host$/ | ||||||||||||||||||||||||||||||||||||||||||
| 210 | && $host ne $s_host ) | ||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | ▶ | if ( $path ne $self->path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | my $path_length = length( $self->path ); | |||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | my $prefix = substr( $path, 0, $path_length ); | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | ▶ | return 0 if $self->path ne $prefix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | my $allowed = ( index( $self->path, q{?} ) >= 0 ) ? q{&} : q{?/}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | ▶ | index( $allowed, substr( $self->path, -1 ) ) >= 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
index($allowed, substr($self->path, -1)) != -1 or index($allowed, substr($path, $path_length, 1)) != -1
MC/DC0%0/2
index($allowed, substr($self->path, -1)) != -1 or index($allowed, substr($path, $path_length, 1)) != -1
index($allowed, substr($self->path, -1)) != -1
index($allowed, substr($path, $path_length, 1)) != -1
Truth table33%1/3
A or B
A= index($allowed, substr($self->path, -1)) != -1B= index($allowed, substr($path, $path_length, 1)) != -1
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | || index( $allowed, substr( $path, $path_length, 1 ) ) >= 0 | ||||||||||||||||||||||||||||||||||||||||||
| 225 | ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | ▶ | no Any::Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||