| 1 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | ############################################################################ | ||||||||||||||||||||||||||||
| 5 | package Net::OpenID::VerifiedIdentity; | ||||||||||||||||||||||||||||
| 6 | BEGIN { | ||||||||||||||||||||||||||||
| 7 | 5 | ▶ | $Net::OpenID::VerifiedIdentity::VERSION = '1.100099_002'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||||||
| 9 | use fields ( | ||||||||||||||||||||||||||||
| 10 | 5 | 'identity', # the verified identity URL | |||||||||||||||||||||||||||
| 11 | 'id_uri', # the verified identity's URI object | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 'claimed_identity', # The ClaimedIdentity object that we've verified | ||||||||||||||||||||||||||||
| 14 | 'semantic_info', # The "semantic info" (RSS URLs, etc) at the verified identity URL | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 'consumer', # The Net::OpenID::Consumer module which created us | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 'signed_fields' , # hashref of key->value of things that were signed. without "openid." prefix | ||||||||||||||||||||||||||||
| 19 | 'signed_message', # the signed fields as an IndirectMessage object. Created when needed. | ||||||||||||||||||||||||||||
| 20 | 5 | ▶ | ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | sub new { | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my Net::OpenID::VerifiedIdentity $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $self = fields::new( $self ) unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | my %opts = @_; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | $self->{'consumer'} = delete $opts{'consumer'}; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ($self->{'claimed_identity'} = delete $opts{'claimed_identity'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | $self->{identity} = $self->{claimed_identity}->claimed_url; | |||||||||||||||||||||||||||
| 32 | 0 | ▶ | unless ($self->{'id_uri'} = URI->new($self->{identity})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | return $self->{'consumer'}->_fail("invalid_uri"); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | for my $par (qw(signed_fields)) { | |||||||||||||||||||||||||||
| 38 | 0 | $self->$par(delete $opts{$par}); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | Carp::croak("Unknown options: " . join(", ", keys %opts)) if %opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | return $self; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | sub url { | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my Net::OpenID::VerifiedIdentity $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
url: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 0 | return $self->{'identity'}; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub display { | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my Net::OpenID::VerifiedIdentity $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
display: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 0 | return DisplayOfURL($self->{'identity'}); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | sub _semantic_info_hash { | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_semantic_info_hash: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | return $self->{semantic_info} if $self->{semantic_info}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | my $sem_info = $self->{claimed_identity}->semantic_info; | |||||||||||||||||||||||||||
| 59 | $self->{semantic_info} = { | ||||||||||||||||||||||||||||
| 60 | 'foaf' => $self->_identity_relative_uri($sem_info->{"foaf"}), | ||||||||||||||||||||||||||||
| 61 | 'foafmaker' => $sem_info->{"foaf.maker"}, | ||||||||||||||||||||||||||||
| 62 | 'rss' => $self->_identity_relative_uri($sem_info->{"rss"}), | ||||||||||||||||||||||||||||
| 63 | 0 | 'atom' => $self->_identity_relative_uri($sem_info->{"atom"}), | |||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||
| 65 | 0 | return $self->{semantic_info}; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | sub _identity_relative_uri { | ||||||||||||||||||||||||||||
| 69 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_identity_relative_uri: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 70 | 0 | my $url = shift; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | return $url if ref $url; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | return undef unless $url; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | return URI->new_abs($url, $self->{'id_uri'}); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub signed_fields { &_getset; } | ||||||||||||||||||||||||||
|
Subroutine
signed_fields: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub foaf { &_getset_semurl; } | ||||||||||||||||||||||||||
|
Subroutine
foaf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub rss { &_getset_semurl; } | ||||||||||||||||||||||||||
|
Subroutine
rss: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub atom { &_getset_semurl; } | ||||||||||||||||||||||||||
|
Subroutine
atom: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub foafmaker { &_getset_sem; } | ||||||||||||||||||||||||||
|
Subroutine
foafmaker: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub declared_foaf { &_dec_semurl; } | ||||||||||||||||||||||||||
|
Subroutine
declared_foaf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub declared_rss { &_dec_semurl; } | ||||||||||||||||||||||||||
|
Subroutine
declared_rss: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub declared_atom { &_dec_semurl; } | ||||||||||||||||||||||||||
|
Subroutine
declared_atom: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub extension_fields { | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | my ($self, $ns_uri) = @_; | ||||||||||||||||||||||||||
|
Subroutine
extension_fields: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 0 | return $self->_extension_fields($ns_uri, $self->{consumer}->message); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | sub signed_extension_fields { | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | my ($self, $ns_uri) = @_; | ||||||||||||||||||||||||||
|
Subroutine
signed_extension_fields: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | return $self->_extension_fields($ns_uri, $self->signed_message); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | sub _extension_fields { | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my ($self, $ns_uri, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_extension_fields: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | return $args->get_ext($ns_uri); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | sub signed_message { | ||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
signed_message: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return $self->{signed_message} if $self->{signed_message}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | # This is maybe a bit hacky. | ||||||||||||||||||||||||||||
| 111 | # We need to synthesize an IndirectMessage object | ||||||||||||||||||||||||||||
| 112 | # representing the signed fields, which means | ||||||||||||||||||||||||||||
| 113 | # that we need to fake up the mandatory message | ||||||||||||||||||||||||||||
| 114 | # arguments that probably weren't signed. | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | my %args = map { 'openid.'.$_ => $self->{signed_fields}{$_} } keys %{$self->{signed_fields}}; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | my $real_message = $self->{consumer}->message; | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | if ($real_message->protocol_version == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | # OpenID 1.1 just needs a mode. | ||||||||||||||||||||||||||||
| 121 | 0 | $args{'openid.mode'} = 'id_res'; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | else { | ||||||||||||||||||||||||||||
| 124 | # OpenID 2.2 needs the namespace URI as well | ||||||||||||||||||||||||||||
| 125 | 0 | $args{'openid.ns'} = 'http://specs.openid.net/auth/2.0'; | |||||||||||||||||||||||||||
| 126 | 0 | $args{'openid.mode'} = 'id_res'; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | my $message = Net::OpenID::IndirectMessage->new(\%args); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | return $self->{signed_message} = $message; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | sub _getset { | ||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_getset: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 136 | 0 | my $param = (caller(1))[3]; | |||||||||||||||||||||||||||
| 137 | 0 | $param =~ s/.+:://; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 0 | my $val = shift; | |||||||||||||||||||||||||||
| 141 | 0 | ▶ | Carp::croak("Too many parameters") if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | $self->{$param} = $val; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 0 | return $self->{$param}; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | sub _getset_sem { | ||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_getset_sem: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 149 | 0 | my $param = (caller(1))[3]; | |||||||||||||||||||||||||||
| 150 | 0 | $param =~ s/.+:://; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | my $info = $self->_semantic_info_hash; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if (my $value = shift) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 0 | ▶ | Carp::croak("Too many parameters") if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 0 | $info->{$param} = $value; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | 0 | return $info->{$param}; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | sub _getset_semurl { | ||||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_getset_semurl: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 163 | 0 | my $param = (caller(1))[3]; | |||||||||||||||||||||||||||
| 164 | 0 | $param =~ s/.+:://; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | my $info = $self->_semantic_info_hash; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (my $surl = shift) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | Carp::croak("Too many parameters") if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | # TODO: make absolute URL from possibly relative one | ||||||||||||||||||||||||||||
| 172 | 0 | my $abs = URI->new_abs($surl, $self->{'id_uri'}); | |||||||||||||||||||||||||||
| 173 | 0 | $info->{$param} = $abs; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | my $uri = $info->{$param}; | |||||||||||||||||||||||||||
| 177 | 0 | ▶ | return $uri && _url_is_under($self->{'id_uri'}, $uri) ? $uri->as_string : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$uri and _url_is_under($self->{"id_uri"}, $uri)
MC/DC0%0/2
$uri and _url_is_under($self->{"id_uri"}, $uri)
$uri
_url_is_under($self->{"id_uri"}, $uri)
Truth table0%0/3
A and B
A= $uriB= _url_is_under($self->{"id_uri"}, $uri)
| |||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | sub _dec_semurl { | ||||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_dec_semurl: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 182 | 0 | my $param = (caller(1))[3]; | |||||||||||||||||||||||||||
| 183 | 0 | $param =~ s/.+::declared_//; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | my $info = $self->_semantic_info_hash; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | my $uri = $info->{$param}; | |||||||||||||||||||||||||||
| 188 | 0 | ▶ | return $uri ? $uri->as_string : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | sub DisplayOfURL { | ||||||||||||||||||||||||||||
| 192 | 0 | ▶ | my $url = shift; | ||||||||||||||||||||||||||
|
Subroutine
DisplayOfURL: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 193 | 0 | my $dev_mode = shift; | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | return $url unless | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | $url =~ m!^https?://([^/]+)(/.*)?$!; | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | my ($host, $path) = ($1, $2); | |||||||||||||||||||||||||||
| 199 | 0 | $host = lc($host); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ($dev_mode) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 0 | $host =~ s!^dev\.!!; | |||||||||||||||||||||||||||
| 203 | 0 | $host =~ s!:\d+!!; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | $host =~ s/:.+//; | |||||||||||||||||||||||||||
| 207 | 0 | $host =~ s/^www\.//i; | |||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if (length($path) <= 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 0 | return $host; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | # obvious username | ||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ($path =~ m!^/~([^/]+)/?$! || | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$path =~ m[^/~([^/]+)/?$] or $path =~ m[^/(?:users?|members?)/([^/]+)/?$]
MC/DC0%0/2
$path =~ m[^/~([^/]+)/?$] or $path =~ m[^/(?:users?|members?)/([^/]+)/?$]
$path =~ m[^/~([^/]+)/?$]
$path =~ m[^/(?:users?|members?)/([^/]+)/?$]
Truth table0%0/3
A or B
A= $path =~ m[^/~([^/]+)/?$]B= $path =~ m[^/(?:users?|members?)/([^/]+)/?$]
| |||||||||||||||||||||||||||||
| 215 | $path =~ m!^/(?:users?|members?)/([^/]+)/?$!) { | ||||||||||||||||||||||||||||
| 216 | 0 | return "$1 [$host]"; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if ($host =~ m!^profile\.(.+)!i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 0 | my $site = $1; | |||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ($path =~ m!^/([^/]+)/?$!) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 0 | return "$1 [$site]"; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | return $url; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | # FIXME: duplicated in Net::OpenID::Server | ||||||||||||||||||||||||||||
| 230 | sub _url_is_under { | ||||||||||||||||||||||||||||
| 231 | 0 | ▶ | my ($root, $test, $err_ref) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_url_is_under: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | my $err = sub { | ||||||||||||||||||||||||||||
| 234 | 0 | ▶ | $$err_ref = shift if $err_ref; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 0 | return undef; | |||||||||||||||||||||||||||
| 236 | 0 | }; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | ▶ | my $ru = ref $root ? $root : URI->new($root); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | return $err->("invalid root scheme") unless $ru->scheme =~ /^https?$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $tu = ref $test ? $test : URI->new($test); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | return $err->("invalid test scheme") unless $tu->scheme =~ /^https?$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 0 | ▶ | return $err->("schemes don't match") unless $ru->scheme eq $tu->scheme; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 0 | ▶ | return $err->("ports don't match") unless $ru->port == $tu->port; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | # check hostnames | ||||||||||||||||||||||||||||
| 246 | 0 | my $ru_host = $ru->host; | |||||||||||||||||||||||||||
| 247 | 0 | my $tu_host = $tu->host; | |||||||||||||||||||||||||||
| 248 | 0 | my $wildcard_host = 0; | |||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($ru_host =~ s!^\*\.!!) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | $wildcard_host = 1; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | 0 | ▶ | unless ($ru_host eq $tu_host) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ($wildcard_host) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 0 | ▶ | return $err->("host names don't match") unless | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | $tu_host =~ /\.\Q$ru_host\E$/; | ||||||||||||||||||||||||||||
| 256 | } else { | ||||||||||||||||||||||||||||
| 257 | 0 | return $err->("host names don't match"); | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | # check paths | ||||||||||||||||||||||||||||
| 262 | 0 | ▶ | my $ru_path = $ru->path || "/"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ru->path || '/'
MC/DC0%0/1
$ru->path || '/'
$ru->path
Truth table0%0/2
A
A= $ru->path
| |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my $tu_path = $tu->path || "/"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$tu->path || '/'
MC/DC0%0/1
$tu->path || '/'
$tu->path
Truth table0%0/2
A
A= $tu->path
| |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | $ru_path .= "/" unless $ru_path =~ m!/$!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | 0 | ▶ | $tu_path .= "/" unless $tu_path =~ m!/$!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 0 | ▶ | return $err->("path not a subpath") unless $tu_path =~ m!^\Q$ru_path\E!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 0 | return 1; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 5 | 1; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | __END__ | ||||||||||||||||||||||||||||