| 1 | package Net::SSH::Any::URI; | ||||||||||||||||||||||||||||||||
| 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 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Encode; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Net::SSH::Any::Util qw(_warn); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 4 | my @slots = qw(scheme user host port path); | |||||||||||||||||||||||||||||||
| 11 | 4 | my %is_slot = map { $_ => $_ } @slots; | |||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 4 | my %alias = (passwd => 'password', pwd => 'password'); | |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 4 | my %unsafe = (password => 1, passphrase => 1); | |||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 4 | my $IPv6_re = qr((?-xism::(?::[0-9a-fA-F]{1,4}){0,5}(?:(?::[0-9a-fA-F]{1,4}){1,2}|:(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})))|[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}|:)|(?::(?:[0-9a-fA-F]{1,4})?|(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))))|:(?:(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|[0-9a-fA-F]{1,4}(?::[0-9a-fA-F]{1,4})?|))|(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|:[0-9a-fA-F]{1,4}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){0,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,2}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,3}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,4}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:)))); | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub uri_escape { | ||||||||||||||||||||||||||||||
|
Subroutine
uri_escape: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 22 | 0 | my $str = shift; | |||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | $str =~ s/([^A-Za-z0-9\-\._~\[\]])/sprintf "%%%02x", ord $1/ge if defined $str; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 24 | 0 | $str | |||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub uri_escape_path { # doesn't escape slashes | ||||||||||||||||||||||||||||||
|
Subroutine
uri_escape_path: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 28 | 0 | my $str = shift; | |||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $str =~ s/([^A-Za-z0-9\-\._~\[\]\/])/sprintf "%%%02x", ord $1/ge if defined $str; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 30 | 0 | $str | |||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub uri_unescape { | ||||||||||||||||||||||||||||||
|
Subroutine
uri_unescape: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 36 | 0 | my $str = shift; | |||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $str =~ s/\%([\da-f]{2})/chr hex $1/ige if defined $str; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 38 | 0 | $str | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=23 SCAR=52.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 42 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | my %opt = (@_ & 1 ? (uri => @_) : @_); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | 3 | $_ = encode(latin1 => $_, Encode::FB_CROAK) for values %opt; | |||||||||||||||||||||||||||||||
| 45 | 3 | my $uri = delete $opt{uri}; | |||||||||||||||||||||||||||||||
| 46 | 3 | my %c_params; | |||||||||||||||||||||||||||||||
| 47 | 3 | my %uri = (c_params => \%c_params); | |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 3 | for (keys %alias) { | |||||||||||||||||||||||||||||||
| 50 | 6 | ▶ | if (defined (my $opt = delete $opt{$_})) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $opt{$alias{$_}} //= $opt; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{$alias{$_}} //= $opt
MC/DC0%0/2
$opt{$alias{$_}} //= $opt
$opt{$alias{$_}}
$opt
Truth table0%0/3
A //= B
A= $opt{$alias{$_}}B= $opt
| |||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 3 | ▶ | if (defined $uri) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if (my ($scheme, $user, $password, $c_params, $ipv6, $host, $port, $path) = | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 57 | $uri =~ m{^ | ||||||||||||||||||||||||||||||||
| 58 | \s* # trim space | ||||||||||||||||||||||||||||||||
| 59 | (?:([\w+-]+)://)?+ # scheme | ||||||||||||||||||||||||||||||||
| 60 | (?: | ||||||||||||||||||||||||||||||||
| 61 | (?:([^\@:;]+))?+ # username | ||||||||||||||||||||||||||||||||
| 62 | (?::([^\@;]*))?+ # : password | ||||||||||||||||||||||||||||||||
| 63 | (?:;([^\@]*))?+ # c-params | ||||||||||||||||||||||||||||||||
| 64 | \@ # @ | ||||||||||||||||||||||||||||||||
| 65 | )?+ | ||||||||||||||||||||||||||||||||
| 66 | (?> # host | ||||||||||||||||||||||||||||||||
| 67 | ( # IPv6... | ||||||||||||||||||||||||||||||||
| 68 | \[$IPv6_re\] # [IPv6] | ||||||||||||||||||||||||||||||||
| 69 | | # or | ||||||||||||||||||||||||||||||||
| 70 | $IPv6_re # IPv6 | ||||||||||||||||||||||||||||||||
| 71 | ) | ||||||||||||||||||||||||||||||||
| 72 | | # or | ||||||||||||||||||||||||||||||||
| 73 | ([^\[\]\@:/]+) # hostname / ipv4 | ||||||||||||||||||||||||||||||||
| 74 | ) | ||||||||||||||||||||||||||||||||
| 75 | (?::([\w\%]+))?+ # port | ||||||||||||||||||||||||||||||||
| 76 | (/.*)?+ # path | ||||||||||||||||||||||||||||||||
| 77 | \s* # trim space | ||||||||||||||||||||||||||||||||
| 78 | $}xo) { | ||||||||||||||||||||||||||||||||
| 79 | 0 | @uri{qw(scheme user port path)} = map uri_unescape($_), $scheme, $user, $port, $path; | |||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (defined $ipv6) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 82 | 0 | $ipv6 =~ /^\[?(.*?)\]?$/; | |||||||||||||||||||||||||||||||
| 83 | 0 | $uri{host} = $1; | |||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||||||
| 86 | 0 | $uri{host} = uri_unescape $host; | |||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $c_params{password} = [uri_unescape $password] if defined $password; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (defined $c_params) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | while ($c_params =~ /\G([^,=]*)=([^,=]*)(?:,|$)/gc) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 93 | 0 | my ($k, $v) = ($1, $2); | |||||||||||||||||||||||||||||||
| 94 | 0 | my $k_unescaped = uri_unescape $k; | |||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | $k_unescaped = $alias{$k_unescaped} // $k_unescaped; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$alias{$k_unescaped} // $k_unescaped
MC/DC0%0/2
$alias{$k_unescaped} // $k_unescaped
$alias{$k_unescaped}
$k_unescaped
Truth table0%0/3
A // B
A= $alias{$k_unescaped}B= $k_unescaped
| |||||||||||||||||||||||||||||||||
| 96 | 0 | push @{$c_params{$k_unescaped}}, uri_unescape $v; | |||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $c_params =~ /\G./gc and return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||||||||||||||
| 102 | 0 | return; | |||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | else { | ||||||||||||||||||||||||||||||||
| 106 | 3 | ▶ | defined $opt{host} or croak "both uri and host are undefined"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 3 | for (@slots) { | |||||||||||||||||||||||||||||||
| 110 | 15 | my $v = delete $opt{$_}; | |||||||||||||||||||||||||||||||
| 111 | 15 | ▶ | $uri{$_} //= $v if defined $v; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$uri{$_} //= $v
MC/DC0%0/2
$uri{$_} //= $v
$uri{$_}
$v
Truth table33%1/3
A //= B
A= $uri{$_}B= $v
| |||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 3 | ▶ | if (defined (my $password = delete $opt{password})) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $uri{c_params}{password} //= [$password]; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri{"c_params"}{"password"} //= [$password]
MC/DC0%0/1
$uri{"c_params"}{"password"} //= [$password]
$uri{"c_params"}{"password"}
Truth table0%0/2
A
A= $uri{"c_params"}{"password"}
| |||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 3 | for (keys %opt) { | |||||||||||||||||||||||||||||||
| 119 | 0 | my $v = delete $opt{$_}; | |||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $c_params{$_} //= [$v] if defined $v; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$c_params{$_} //= [$v]
MC/DC0%0/1
$c_params{$_} //= [$v]
$c_params{$_}
Truth table0%0/2
A
A= $c_params{$_}
| |||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 3 | my $self = \%uri; | |||||||||||||||||||||||||||||||
| 124 | 3 | bless $self, $class; | |||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 4 | for my $slot (@slots) { | |||||||||||||||||||||||||||||||
| 128 | 6 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=22.9
| |||||||||||||||||||||||||||||||||
| 129 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||
| 130 | 6 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if (defined (my $v = shift)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 132 | 0 | $self->{$slot} = encode latin1 => $v, Encode::FB_CROAK; | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | $slot eq 'host' and croak "attribute host is mandatory"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | 0 | delete $self->{$slot}; | |||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | 0 | return; | |||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | 6 | $self->{$slot}; | |||||||||||||||||||||||||||||||
| 141 | 20 | }; | |||||||||||||||||||||||||||||||
| 142 | 4 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 143 | 20 | *$slot = $sub; | |||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub bracketed_host { | ||||||||||||||||||||||||||||||
|
Subroutine
bracketed_host: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 147 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | @_ and croak 'bracketed_host is read only'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 149 | 0 | my $h = $self->{host}; | |||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | ($h =~ /^$IPv6_re$/o ? "[$h]" : $h); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub c_params { | ||||||||||||||||||||||||||||||
|
Subroutine
c_params: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 154 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $c_params = $self->{c_params} or return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 156 | 0 | my @out; | |||||||||||||||||||||||||||||||
| 157 | 0 | for my $k (%$c_params) { | |||||||||||||||||||||||||||||||
| 158 | 0 | push @out, map { $k, $_ } @{$c_params->{$k}}; | |||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||
| 160 | 0 | @out; | |||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | sub c_param_count { | ||||||||||||||||||||||||||||||
|
Subroutine
c_param_count: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 164 | 0 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $key = $alias{$key} // $key; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$alias{$key} // $key
MC/DC0%0/2
$alias{$key} // $key
$alias{$key}
$key
Truth table0%0/3
A // B
A= $alias{$key}B= $key
| |||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | my $c_params = $self->{c_params} or return 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | my $vs = $c_params->{$key} or return 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 168 | 0 | scalar (@$vs); | |||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub c_param { | ||||||||||||||||||||||||||||||
|
Subroutine
c_param: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 172 | 0 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $key = $alias{$key} // $key; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$alias{$key} // $key
MC/DC0%0/2
$alias{$key} // $key
$alias{$key}
$key
Truth table0%0/3
A // B
A= $alias{$key}B= $key
| |||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | my $c_params = $self->{c_params} or return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my $vs = $c_params->{$key} or return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | wantarray or croak "c_param used in scalar context is not supported"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 177 | 0 | @$vs; | |||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub set_c_param { | ||||||||||||||||||||||||||||||
|
Subroutine
set_c_param: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 181 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 182 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $key = $alias{$key} // $key; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$alias{$key} // $key
MC/DC0%0/2
$alias{$key} // $key
$alias{$key}
$key
Truth table0%0/3
A // B
A= $alias{$key}B= $key
| |||||||||||||||||||||||||||||||||
| 184 | 0 | $self->{c_params}{$key} = [@_]; | |||||||||||||||||||||||||||||||
| 185 | return | ||||||||||||||||||||||||||||||||
| 186 | 0 | } | |||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | sub password { | ||||||||||||||||||||||||||||||
|
Subroutine
password: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 189 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 190 | 0 | $self->{c_params}{password}[0]; | |||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 194 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 195 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | $key = $alias{$key} // $key; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$alias{$key} // $key
MC/DC0%0/2
$alias{$key} // $key
$alias{$key}
$key
Truth table0%0/3
A // B
A= $alias{$key}B= $key
| |||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | my @r = $self->{$key} // do { | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{$key} // do {
my $a = $self->{"c_params"}{$key};
$a ? @$a : ()
}
MC/DC0%0/2
$self->{$key} // do {
my $a = $self->{"c_params"}{$key};
$a ? @$a : ()
}
$self->{$key}
do {
my $a = $self->{"c_params"}{$key};
$a ? @$a : ()
}
Truth table0%0/3
A // B
A= $self->{$key}B= do {
my $a = $self->{"c_params"}{$key};
$a ? @$a : ()
}
| |||||||||||||||||||||||||||||||||
| 198 | 0 | my $a = $self->{c_params}{$key}; | |||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | ($a ? @$a : ()) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 200 | }; | ||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if (@r > 1 and not wantarray) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@r > 1 and not wantarray
MC/DC0%0/2
@r > 1 and not wantarray
@r > 1
not wantarray
Truth table0%0/3
A and not(B)
A= @r > 1B= not wantarray
| |||||||||||||||||||||||||||||||||
| 202 | 0 | _warn("\$uri->get($key) called on scalar context when it contains more than one entry"); | |||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | wantarray ? @r : $r[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub set { | ||||||||||||||||||||||||||||||
|
Subroutine
set: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 208 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 209 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | $key = $alias{$key} // $key; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$alias{$key} // $key
MC/DC0%0/2
$alias{$key} // $key
$alias{$key}
$key
Truth table0%0/3
A // B
A= $alias{$key}B= $key
| |||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ($is_slot{$key}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | @_ > 1 and _warn "URI attribute $key is an scalar but set($key) called with ".scalar(@_)." arguments"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 213 | 0 | $self->$key($_[0]); | |||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||
| 215 | else { | ||||||||||||||||||||||||||||||||
| 216 | 0 | $self->set_c_param($key, @_); | |||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||
| 218 | () | ||||||||||||||||||||||||||||||||
| 219 | 0 | } | |||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub or_set { | ||||||||||||||||||||||||||||||
|
Subroutine
or_set: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 222 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 223 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | $key = $alias{$key} // $key; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$alias{$key} // $key
MC/DC0%0/2
$alias{$key} // $key
$alias{$key}
$key
Truth table0%0/3
A // B
A= $alias{$key}B= $key
| |||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | $self->set($key, @_) unless defined $self->{$key} or defined $self->{c_params}{$key}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{$key} or defined $self->{"c_params"}{$key}
MC/DC0%0/2
defined $self->{$key} or defined $self->{"c_params"}{$key}
defined $self->{$key}
defined $self->{"c_params"}{$key}
Truth table0%0/3
A or B
A= defined $self->{$key}B= defined $self->{"c_params"}{$key}
| |||||||||||||||||||||||||||||||||
| 226 | () | ||||||||||||||||||||||||||||||||
| 227 | 0 | } | |||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub _c_params_escaped { | ||||||||||||||||||||||||||||||
|
Subroutine
_c_params_escaped: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||
| 230 | 0 | my ($self, $safe) = @_; | |||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | my $c_params = $self->{c_params} // return; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"c_params"} // (return)
MC/DC0%0/1
$self->{"c_params"} // (return)
$self->{"c_params"}
Truth table0%0/2
A
A= $self->{"c_params"}
| |||||||||||||||||||||||||||||||||
| 232 | 0 | my @parts; | |||||||||||||||||||||||||||||||
| 233 | 0 | my $ix = 0; | |||||||||||||||||||||||||||||||
| 234 | 0 | for my $k (sort keys %$c_params) { | |||||||||||||||||||||||||||||||
| 235 | 0 | my $k_escaped = uri_escape $k; | |||||||||||||||||||||||||||||||
| 236 | 0 | for my $v (@{$c_params->{$k}}) { | |||||||||||||||||||||||||||||||
| 237 | push(@parts, ($ix++ ? ',' : ';'), $k_escaped, '=', | ||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | (($safe and $unsafe{$k}) ? '*****' : uri_escape $v)); | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$safe and $unsafe{$k}
MC/DC0%0/2
$safe and $unsafe{$k}
$safe
$unsafe{$k}
Truth table0%0/3
A and B
A= $safeB= $unsafe{$k}
| |||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||
| 241 | 0 | @parts; | |||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub uri { | ||||||||||||||||||||||||||||||
|
Subroutine
uri: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 245 | 0 | my ($self, $safe) = @_; | |||||||||||||||||||||||||||||||
| 246 | 0 | my @parts; | |||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | push @parts, uri_escape($self->{user}) if defined $self->{user}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 248 | 0 | push @parts, $self->_c_params_escaped($safe); | |||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | push @parts, '@', if @parts; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | unshift @parts, uri_escape($self->{scheme}), '://' if defined $self->{scheme}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 251 | 0 | my $h = $self->{host}; | |||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | push @parts, ($h =~ /^$IPv6_re$/o ? "[$h]" : uri_escape($h)); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | push @parts, ':', uri_escape($self->{port}) if defined $self->{port}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | push @parts, uri_escape_path($self->{path}) if defined $self->{path}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 255 | 0 | join '', @parts; | |||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||
| 258 | 4 | *as_string = \&uri; | |||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||
| 260 | 4 | 1; | |||||||||||||||||||||||||||||||