| 1 | package Rose::URI; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Carp(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use URI::Escape(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Rose::Object; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | our @ISA = qw(Rose::Object); | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | use overload | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 17 | ▶ | '""' => sub { shift->as_string }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | 'bool' => sub { length shift->as_string }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | fallback => 1, | |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | our $Make_URI; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our $SCHEME_RE = '[a-zA-Z][a-zA-Z0-9.+\-]*'; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | our $VERSION = '1.00'; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # Class data | ||||||||||||||||||||||||||||||||||||||||||
| 25 | use Rose::Class::MakeMethods::Generic | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | inheritable_scalar => | |||||||||||||||||||||||||||||||||||||||||
| 28 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 'default_query_param_separator', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 'default_omit_empty_query_params', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | # Object data | ||||||||||||||||||||||||||||||||||||||||||
| 35 | use Rose::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | scalar => | |||||||||||||||||||||||||||||||||||||||||
| 38 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 'username', | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 'password', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 'scheme', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 'host', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 'port', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 'path', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 'fragment', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 'query_param_separator' => { interface => 'get_set_init' }, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | __PACKAGE__->default_query_param_separator('&'); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | __PACKAGE__->default_omit_empty_query_params(0); | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 23 | ▶ | sub init_query_param_separator { ref(shift)->default_query_param_separator } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_query_param_separator: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 23 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 23 | my($class) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 23 | my $self = | |||||||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | username => '', | ||||||||||||||||||||||||||||||||||||||||||
| 62 | password => '', | ||||||||||||||||||||||||||||||||||||||||||
| 63 | scheme => '', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | host => '', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | port => '', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | path => '', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | query => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | fragment => '', | ||||||||||||||||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 23 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 23 | $self->init(@_); | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 23 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | sub init | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 23 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 23 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 23 | ▶ | if(@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 23 | $self->init_with_uri(@_); | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | else | ||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->SUPER::init(@_); | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | sub init_with_uri | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 23 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_with_uri: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 23 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 23 | $self->$Make_URI($_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | sub clone | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | return bless _deep_copy($self), ref($self); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | sub parse_query | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 27 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_query: called CC=11 SCAR=25.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 27 | my($self, $query) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 27 | $self->{'query_string'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 27 | ▶ | unless(defined $query && $query =~ /\S/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $query and $query =~ /\S/
MC/DC0%0/2
defined $query and $query =~ /\S/
defined $query
$query =~ /\S/
Truth table33%1/3
A and B
A= defined $queryB= $query =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->{'query'} = { }; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 27 | my @params; | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 27 | ▶ | if(index($query, '&') >= 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 22 | @params = split(/&/, $query); | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | elsif(index($query, ';') >= 0) | ||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | @params = split(/;/, $query); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | elsif(index($query, '=') < 0) | ||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | $self->{'query_string'} = __unescape_uri($query); | |||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | $self->{'query'} = { $self->{'query_string'} => undef }; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 25 | ▶ | @params = ($query) unless(@params); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 25 | my %query; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 25 | foreach my $item (@params) | |||||||||||||||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 78 | my($param, $value) = map { __unescape_uri($_) } split(/=/, $item); | |||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 78 | ▶ | $param = __unescape_uri($item) unless(defined($param)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 78 | ▶ | if(exists $query{$param}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 25 | ▶ | if(ref $query{$param}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | push(@{$query{$param}}, $value); | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | else | ||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 25 | $query{$param} = [ $query{$param}, $value ]; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | else | ||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 53 | $query{$param} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 25 | $self->{'query'} = \%query; | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 25 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | sub query_hash | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_hash: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | ▶ | return (wantarray) ? %{$self->{'query'}} : { %{$self->{'query'}} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | sub omit_empty_query_params | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
omit_empty_query_params: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 6 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | ▶ | return $self->{'omit_empty_query_params'} = $_[0] ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | return defined $self->{'omit_empty_query_params'} ? | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | ▶ | $self->{'omit_empty_query_params'} : ref($self)->default_omit_empty_query_params; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | sub query_param | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 132 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_param: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 132 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 132 | ▶ | if(@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 117 | ▶ | return $self->{'query'}{$_[0]} if(exists $self->{'query'}{$_[0]}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | elsif(@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 15 | $self->{'query_string'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 15 | ▶ | if(ref $_[1]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | return $self->{'query'}{$_[0]} = [ @{$_[1]} ]; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 9 | return $self->{'query'}{$_[0]} = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | Carp::croak "query_param() takes either one or two arguments"; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | sub query_params | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 119 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_params: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 119 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 119 | ▶ | return sort keys %{$self->{'query'}} unless(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 118 | my $params = $self->query_param(@_); | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 118 | ▶ | $params = (ref $params) ? [ @$params ] : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | (defined $params) ? [ $params ] : []; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 118 | ▶ | return (wantarray) ? @$params : $params; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | sub query_param_add | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_param_add: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 5 | my($self, $name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 5 | ▶ | Carp::croak "query_add_param() takes two arguments" unless(@_ == 3); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 5 | my $params = $self->query_params($name); | |||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 5 | ▶ | push(@$params, (ref $value) ? @$value : $value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 5 | ▶ | $self->query_param($name => (@$params > 1) ? $params : $params->[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 5 | ▶ | return (wantarray) ? @$params : $params; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | sub query_param_exists | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_param_exists: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 7 | my($self, $param) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 7 | ▶ | Carp::croak "Missing query param argument" unless(defined $param); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 7 | return exists $self->{'query'}{$param}; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | sub query_param_delete | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_param_delete: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | Carp::croak "query_param_delete() takes one or more arguments" unless(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | foreach my $param (@_) | |||||||||||||||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | ▶ | if(defined $self->{'query_string'} && $param eq $self->{'query_string'}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"query_string"} and $param eq $self->{"query_string"}
MC/DC100%2/2
defined $self->{"query_string"} and $param eq $self->{"query_string"}
defined $self->{"query_string"}
$param eq $self->{"query_string"}
Truth table100%3/3
A and B
A= defined $self->{"query_string"}B= $param eq $self->{"query_string"}
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | $self->{'query_string'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | delete $self->{'query'}{$param}; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 31 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 31 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 31 | my $scheme = $self->scheme; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 31 | my $user = $self->userinfo_escaped; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 31 | my $port = $self->port; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 31 | my $query = $self->query; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 31 | my $frag = __escape_uri($self->fragment); | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 31 | ▶ | return ((length $scheme) ? "$scheme://" : '') . | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | ((length $user) ? "$user\@" : '') . | ||||||||||||||||||||||||||||||||||||||||||
| 277 | $self->host . | ||||||||||||||||||||||||||||||||||||||||||
| 278 | ((length $port) ? ":$port" : '') . | ||||||||||||||||||||||||||||||||||||||||||
| 279 | __escape_uri_whole($self->path) . | ||||||||||||||||||||||||||||||||||||||||||
| 280 | ((length $query) ? "?$query" : '') . | ||||||||||||||||||||||||||||||||||||||||||
| 281 | ((length $frag) ? "#$frag" : ''); | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | sub query | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 54 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 54 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 54 | ▶ | if(@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | { | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 6 | ▶ | if(ref $_[0]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | $self->{'query'} = _deep_copy($_[0]) | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | else | ||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 4 | $self->parse_query($_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | elsif(@_) | ||||||||||||||||||||||||||||||||||||||||||
| 300 | { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | $self->{'query'} = _deep_copy({ @_ }); | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 54 | my $want = wantarray; | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 54 | ▶ | return unless(defined wantarray); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 47 | ▶ | if(defined $self->{'query_string'}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 3 | return __escape_uri($self->{'query_string'}); | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 44 | my(@query, $omit_empty); | |||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 44 | foreach my $param (sort keys %{$self->{'query'}}) | |||||||||||||||||||||||||||||||||||||||||
| 316 | { | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 103 | my @values = $self->query_params($param); | |||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | # Contortions to avoid calling this method in the common(?) case where | ||||||||||||||||||||||||||||||||||||||||||
| 320 | # every query parameter has at least one value. | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 103 | ▶ | if(!@values && !(defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params))) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
@values or defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)
MC/DC100%2/2
@values or defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)
@values
defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)
Truth table100%3/3
A or B
A= @valuesB= defined $omit_empty ? $omit_empty : ($omit_empty = $self->omit_empty_query_params)
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 4 | @values = (''); | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 103 | foreach my $value (@values) | |||||||||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 143 | push(@query, __escape_uri($param) . '=' . __escape_uri($value)); | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 44 | return join($self->query_param_separator, @query); | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | sub query_form | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_form: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 2 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 2 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | $self->{'query_string'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 1 | $self->{'query'} = { }; | |||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 1 | ▶ | for(my $i = 0; $i < $#_; $i += 2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 3 | $self->query_param_add($_[$i] => $_[$i + 1]); | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 2 | ▶ | return unless(defined(wantarray)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | my @query; | |||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | foreach my $param ($self->query_params) | |||||||||||||||||||||||||||||||||||||||||
| 355 | { | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | foreach my $value ($self->query_params($param)) | |||||||||||||||||||||||||||||||||||||||||
| 357 | { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 3 | push(@query, $param, $value); | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 1 | return @query; | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | sub abs | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abs: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 5 | my($self, $base) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 5 | ▶ | return $self unless($base && !length $self->scheme); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$base and not length $self->scheme
MC/DC50%1/2
$base and not length $self->scheme
$base
not length $self->scheme
Truth table66%2/3
A and not(B)
A= $baseB= not length $self->scheme
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 4 | my $new = $self->as_string; | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | $new =~ s{^/}{}; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | $base =~ s{/$}{}; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | ▶ | return Rose::URI->new("/$new") unless($base =~ m{^$SCHEME_RE://}o); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 4 | return Rose::URI->new("$base/$new"); | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | sub rel | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rel: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 6 | my($self, $base) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 6 | ▶ | return $self unless($base); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 5 | my $uri = $self->as_string; | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 5 | ▶ | if($uri =~ m{^$base/?}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | { | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 2 | $uri =~ s{^$base/?}{}; | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 2 | return Rose::URI->new($uri); | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | sub userinfo | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
userinfo: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $user = $self->username; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my $pass = $self->password; | |||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if(length $user && length $pass) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $user and length $pass
MC/DC0%0/2
length $user and length $pass
length $user
length $pass
Truth table0%0/3
A and B
A= length $userB= length $pass
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | { | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | return join(':', $user, $pass); | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | return $user if(length $user); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | sub userinfo_escaped | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 31 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
userinfo_escaped: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 31 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 31 | my $user = __escape_uri($self->username); | |||||||||||||||||||||||||||||||||||||||||
| 419 | 31 | my $pass = __escape_uri($self->password); | |||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 31 | ▶ | if(length $user && length $pass) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $user and length $pass
MC/DC50%1/2
length $user and length $pass
length $user
length $pass
Truth table66%2/3
A and B
A= length $userB= length $pass
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 20 | return join(':', $user, $pass); | |||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 11 | ▶ | return $user if(length $user); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 11 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | sub __uri_from_apache_uri | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__uri_from_apache_uri: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $uri = Apache::URI->parse(Apache->request, @_); | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | $self->{'username'} = $uri->user || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri->user || ''
MC/DC0%0/1
$uri->user || ''
$uri->user
Truth table0%0/2
A
A= $uri->user
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | $self->{'password'} = $uri->password || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri->password || ''
MC/DC0%0/1
$uri->password || ''
$uri->password
Truth table0%0/2
A
A= $uri->password
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | $self->{'scheme'} = $uri->scheme || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri->scheme || ''
MC/DC0%0/1
$uri->scheme || ''
$uri->scheme
Truth table0%0/2
A
A= $uri->scheme
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | $self->{'host'} = $uri->hostname || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri->hostname || ''
MC/DC0%0/1
$uri->hostname || ''
$uri->hostname
Truth table0%0/2
A
A= $uri->hostname
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $self->{'port'} = $uri->port || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri->port || ''
MC/DC0%0/1
$uri->port || ''
$uri->port
Truth table0%0/2
A
A= $uri->port
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | $self->{'path'} = $uri->path || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri->path || ''
MC/DC0%0/1
$uri->path || ''
$uri->path
Truth table0%0/2
A
A= $uri->path
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | $self->{'fragment'} = $uri->fragment || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri->fragment || ''
MC/DC0%0/1
$uri->fragment || ''
$uri->fragment
Truth table0%0/2
A
A= $uri->fragment
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $self->parse_query($uri->query); | |||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | return $uri; | |||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | sub __uri_from_uri | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 23 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__uri_from_uri: called CC=13 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 23 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 23 | my $uri = URI->new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 23 | ▶ | if($uri->can('user')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | { | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $self->{'username'} = $uri->user; | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | elsif($uri->can('userinfo')) | ||||||||||||||||||||||||||||||||||||||||||
| 460 | { | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 14 | ▶ | if(my $userinfo = $uri->userinfo) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | { | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 10 | ▶ | if(my($user, $pass) = split(':', $userinfo)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | { | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 10 | $self->{'username'} = __unescape_uri($user); | |||||||||||||||||||||||||||||||||||||||||
| 466 | 10 | $self->{'password'} = __unescape_uri($pass); | |||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 23 | ▶ | $self->{'scheme'} = __unescape_uri($uri->scheme || ''); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$uri->scheme || ''
MC/DC100%1/1
$uri->scheme || ''
$uri->scheme
Truth table100%2/2
A
A= $uri->scheme
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 23 | ▶ | $self->{'host'} = __unescape_uri($uri->host || '') if($uri->can('host')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$uri->host || ''
MC/DC0%0/1
$uri->host || ''
$uri->host
Truth table50%1/2
A
A= $uri->host
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 23 | ▶ | $self->{'port'} = __unescape_uri($uri->_port || '') if($uri->can('_port')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$uri->_port || ''
MC/DC0%0/1
$uri->_port || ''
$uri->_port
Truth table50%1/2
A
A= $uri->_port
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 23 | ▶ | $self->{'path'} = __unescape_uri($uri->path || '') if($uri->can('path')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$uri->path || ''
MC/DC0%0/1
$uri->path || ''
$uri->path
Truth table50%1/2
A
A= $uri->path
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 23 | ▶ | $self->{'fragment'} = __unescape_uri($uri->fragment || ''); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$uri->fragment || ''
MC/DC100%1/1
$uri->fragment || ''
$uri->fragment
Truth table100%2/2
A
A= $uri->fragment
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 23 | $self->parse_query($uri->query); | |||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 23 | return $uri; | |||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 2 | ▶ | if(exists $ENV{'MOD_PERL'} && require mod_perl && $mod_perl::VERSION < 1.99) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $ENV{"MOD_PERL"} and require mod_perl and $mod_perl::VERSION < "1.99"
exists $ENV{"MOD_PERL"} and require mod_perl
MC/DC0%0/3
exists $ENV{"MOD_PERL"} and require mod_perl and $mod_perl::VERSION < "1.99"
exists $ENV{"MOD_PERL"}
require mod_perl
$mod_perl::VERSION < "1.99"
Truth table25%1/4
A and B and C
A= exists $ENV{"MOD_PERL"}B= require mod_perlC= $mod_perl::VERSION < "1.99"
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | { | ||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | require Apache; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | require Apache::URI; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | require Apache::Util; | |||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | *__escape_uri = \&Apache::Util::escape_uri; | |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | *__unescape_uri = \&Apache::Util::unescape_uri_info; | |||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $Make_URI = \&__uri_from_apache_uri; | |||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | else | ||||||||||||||||||||||||||||||||||||||||||
| 494 | { | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 2 | *__escape_uri = \&URI::Escape::uri_escape; | |||||||||||||||||||||||||||||||||||||||||
| 496 | *__unescape_uri = sub | ||||||||||||||||||||||||||||||||||||||||||
| 497 | 273 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | 273 | my $e = URI::Escape::uri_unescape(@_); | |||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | 273 | $e =~ s/\+/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 273 | return $e; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | require URI; | |||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | $Make_URI = \&__uri_from_uri; | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | sub __escape_uri_whole | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 31 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__escape_uri_whole: called CC=3 SCAR=16.0
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 31 | ▶ | URI::Escape::uri_escape($_[0], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | (@_ > 1) ? (defined $_[1] ? $_[1] : ()) : q(^A-Za-z0-9\-_.,'!~*#?&()/?@\:\[\]=)); | ||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | # Based on code from Clone::PP | ||||||||||||||||||||||||||||||||||||||||||
| 516 | sub _deep_copy | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deep_copy: called CC=9 SCAR=23.6
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 10 | my($data) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | 10 | ▶ | my $ref_type = ref $data or return $data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | 10 | my $copy; | |||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | 10 | ▶ | if($ref_type eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | { | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 5 | $copy = {}; | |||||||||||||||||||||||||||||||||||||||||
| 527 | 5 | ▶ | %$copy = map { !ref($_) ? $_ : _deep_copy($_) } %$data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | elsif($ref_type eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||
| 530 | { | ||||||||||||||||||||||||||||||||||||||||||
| 531 | 4 | $copy = []; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 4 | ▶ | @$copy = map { !ref($_) ? $_ : _deep_copy($_) } @$data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 534 | ▶ | elsif($ref_type eq 'REF' or $ref_type eq 'SCALAR') | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ref_type eq "REF" or $ref_type eq "SCALAR"
MC/DC0%0/2
$ref_type eq "REF" or $ref_type eq "SCALAR"
$ref_type eq "REF"
$ref_type eq "SCALAR"
Truth table33%1/3
A or B
A= $ref_type eq "REF"B= $ref_type eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | { | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $copy = \(my $var = ''); | |||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $$copy = _deep_copy($$data); | |||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | elsif($ref_type->isa(__PACKAGE__)) # cloning | ||||||||||||||||||||||||||||||||||||||||||
| 540 | { | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | $copy = _deep_copy({ %{$data} }); | |||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | else | ||||||||||||||||||||||||||||||||||||||||||
| 544 | { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | $copy = $data; | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 10 | return $copy; | |||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | __END__ | ||||||||||||||||||||||||||||||||||||||||||