| 1 | package CGI::Application::Plugin::Apache; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use vars qw(@EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use constant MP => exists($ENV{MOD_PERL}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use constant MP2 => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | (MP() and exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} == 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # only do stuff if we are running under mod_perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | if( MP ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | @EXPORT_OK = qw(handler cgiapp_get_query _send_headers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | %EXPORT_TAGS = (all => \@EXPORT_OK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # if we are under mod_perl 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | if( MP2() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | require Apache2::Const; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | require Apache2::RequestRec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | require Apache2::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | Apache2::Const->import(-compile => qw(OK REDIRECT)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | require Apache::Constants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | require Apache::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | Apache::Constants->import(qw(OK REDIRECT)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | @EXPORT_OK = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | %EXPORT_TAGS = (all => []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub handler : method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my ($class, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # run it with our new query object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $class->new(QUERY => _get_apreq($r))->run(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # return the appropriate code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | if( MP2() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | return Apache2::Const::OK(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return Apache::Constants::OK(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # get the appropriate query object based on CAPA_CGI_Compat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # and mod_perl 1/2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub _get_apreq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_apreq: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $r = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $query; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if(lc($r->dir_config('CAPA_CGI_Compat')) eq 'on') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | if( MP2() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | require CGI::Application::Plugin::Apache2::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $query = CGI::Application::Plugin::Apache2::Request->new( $r ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | require CGI::Application::Plugin::Apache::Request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $query = CGI::Application::Plugin::Apache::Request->new( $r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $query = MP2() ? Apache2::Request->new($r) : Apache::Request->new($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return $query; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # override C::A's loading of CGI.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub cgiapp_get_query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cgiapp_get_query: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $r = MP2() ? Apache2::RequestUtil->request() : Apache->request(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return _get_apreq($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub _send_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_send_headers: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $header_type = $self->header_type(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my %props = $self->header_props(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # if we are redirecting set the status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if($header_type eq 'redirect') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | if( MP2() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | $q->status(Apache2::Const::REDIRECT()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $q->status(Apache::Constants::REDIRECT()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # if we are redirecting try and do it with header_out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ( $header_type eq 'redirect' || $header_type eq 'header' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$header_type eq "redirect" or $header_type eq "header"
MC/DC0%0/2
$header_type eq "redirect" or $header_type eq "header"
$header_type eq "redirect"
$header_type eq "header"
Truth table0%0/3
A or B
A= $header_type eq "redirect"B= $header_type eq "header"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # if we have any header props then use our CGI compat to handle them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if( scalar(keys %props) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | _handle_cgi_header_props($q, %props); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # else use to Apache send the header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if( MP2() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | $q->content_type('text/html') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | unless $q->content_type(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } elsif( $q->content_type() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $q->send_http_header() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $q->send_http_header('text/html') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } elsif( $header_type eq 'none' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # don't do anything here either... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # croak() if we have an unknown header type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | croak ("Invalid header_type '$header_type'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Don't return anything so headers aren't sent twice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | #THE FOLLOWING SUBS ARE ADAPTED FROM Lincoln Stein's CGI.pm module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub _handle_cgi_header_props { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_cgi_header_props: not called CC=19 SCAR=59.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my($q,@p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my($type,$status,$cookie,$target,$expires,$charset,$attachment,$p3p,$uri,$other) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | _rearrange_props( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ['TYPE','CONTENT_TYPE','CONTENT-TYPE'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 'STATUS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ['COOKIE','COOKIES'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 'TARGET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 'EXPIRES', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 'CHARSET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 'ATTACHMENT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 'P3P', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 'URI', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | @p | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $type ||= 'text/html'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$type ||= "text/html"
MC/DC0%0/1
$type ||= "text/html"
$type
Truth table0%0/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | $type .= "; charset=$charset" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$type =~ m[^text/] and not $type =~ /\bcharset\b/ and $charset
$type =~ m[^text/] and not $type =~ /\bcharset\b/
MC/DC0%0/3
$type =~ m[^text/] and not $type =~ /\bcharset\b/ and $charset
$type =~ m[^text/]
not $type =~ /\bcharset\b/
$charset
Truth table0%0/4
A and not(B) and C
A= $type =~ m[^text/]B= not $type =~ /\bcharset\b/C= $charset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | if( $type =~ m!^text/! and $type !~ /\bcharset\b/ and $charset ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $q->content_type($type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $q->status($status) if($status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if( $target ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $q->headers_out->{'Window-Target'} = $target; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ( $p3p ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $p3p = join ' ',@$p3p if ref($p3p) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $q->headers_out->{'P3P'} = qq(policyref="/w3c/p3p.xml"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $q->headers_out->{'CP'} = $p3p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # send all the cookies -- there may be several | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ( $cookie ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | my(@cookie) = ref($cookie) && ref($cookie) eq 'ARRAY' ? @{$cookie} : $cookie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $cookie and ref $cookie eq "ARRAY"
MC/DC0%0/2
ref $cookie and ref $cookie eq "ARRAY"
ref $cookie
ref $cookie eq "ARRAY"
Truth table0%0/3
A and B
A= ref $cookieB= ref $cookie eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | foreach (@cookie) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $cs = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if( UNIVERSAL::isa($_,'CGI::Cookie') || (MP2() ? UNIVERSAL::isa($_, 'Apache2::Cookie') : UNIVERSAL::isa($_,'Apache::Cookie') ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
UNIVERSAL::isa($_, "CGI::Cookie") or UNIVERSAL::isa($_, "Apache::Cookie")
MC/DC0%0/2
UNIVERSAL::isa($_, "CGI::Cookie") or UNIVERSAL::isa($_, "Apache::Cookie")
UNIVERSAL::isa($_, "CGI::Cookie")
UNIVERSAL::isa($_, "Apache::Cookie")
Truth table0%0/3
A or B
A= UNIVERSAL::isa($_, "CGI::Cookie")B= UNIVERSAL::isa($_, "Apache::Cookie")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $cs = $_->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $cs = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $q->headers_out->add('Set-Cookie' => $cs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # if the user indicates an expiration time, then we need an Expires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if( $expires ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $q->headers_out('Expires' => _expires($expires,'http')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # if there's a location...this is generally done for redirects but there may be other reasons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if( $uri ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $q->headers_out->{'Location'} = $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if( $attachment ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $q->headers_out->{'Content-Disposition'} = qq(attachment; filename="$attachment"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | foreach my $key (keys %$other) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $q->headers_out->{ucfirst($key)} = $other->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $q->send_http_header() unless(MP2()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub _rearrange_props { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rearrange_props: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my($order,@param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # map parameters into positional indices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($i,%pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | foreach (@$order) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | foreach (ref($_) eq 'ARRAY' ? @$_ : $_) { $pos{lc($_)} = $i; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my (@result,%leftover); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $#result = $#$order; # preextend | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | while (@param) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $key = lc(shift(@param)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $key =~ s/^\-//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if (exists $pos{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $result[$pos{$key}] = shift(@param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $leftover{$key} = shift(@param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | push (@result,\%leftover) if %leftover; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | return @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # This internal routine creates date strings suitable for use in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # cookies and HTTP headers. (They differ, unfortunately.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # Thanks to Mark Fisher for this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub _expires { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expires: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my($time,$format) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $format ||= 'http'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$format ||= "http"
MC/DC0%0/1
$format ||= "http"
$format
Truth table0%0/2
A
A= $format
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my(@MON)=qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my(@WDAY) = qw/Sun Mon Tue Wed Thu Fri Sat/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # pass through preformatted dates for the sake of _expire_calc() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $time = _expire_calc($time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | return $time unless $time =~ /^\d+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # make HTTP/cookie date string from GMT'ed time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # (cookies use '-' as date separator, HTTP uses ' ') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my($sc) = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | $sc = '-' if $format eq "cookie"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime($time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $year += 1900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | return sprintf("%s, %02d$sc%s$sc%04d %02d:%02d:%02d GMT", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | $WDAY[$wday],$mday,$MON[$mon],$year,$hour,$min,$sec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # This internal routine creates an expires time exactly some number of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # hours from the current time. It incorporates modifications from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # Mark Fisher. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub _expire_calc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expire_calc: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my($time) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my(%mult) = ('s'=>1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 'm'=>60, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 'h'=>60*60, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 'd'=>60*60*24, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 'M'=>60*60*24*30, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 'y'=>60*60*24*365); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # format for time can be in any of the forms... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # "now" -- expire immediately | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # "+180s" -- in 180 seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # "+2m" -- in 2 minutes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # "+12h" -- in 12 hours | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # "+1d" -- in 1 day | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # "+3M" -- in 3 months | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # "+2y" -- in 2 years | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # "-3m" -- 3 minutes ago(!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # If you don't supply one of these forms, we assume you are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # specifying the date yourself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my($offset); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (!$time || (lc($time) eq 'now')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
not $time or lc $time eq "now"
MC/DC0%0/2
not $time or lc $time eq "now"
not $time
lc $time eq "now"
Truth table0%0/3
not(A) or B
A= not $timeB= lc $time eq "now"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } elsif ($time=~/^\d+/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | return $time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } elsif ($time=~/^([+-]?(?:\d+|\d*\.\d*))([mhdMy]?)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | $offset = ($mult{$2} || 1)*$1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mult{$2} || 1
MC/DC0%0/1
$mult{$2} || 1
$mult{$2}
Truth table0%0/2
A
A= $mult{$2}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | return $time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | return (time+$offset); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub _unescapeHTML { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unescapeHTML: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my ($string, $charset) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | return undef unless defined($string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | my $latin = defined $charset ? $charset =~ /^(ISO-8859-1|WINDOWS-1252)$/i : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # thanks to Randal Schwartz for the correct solution to this one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $string=~ s[&(.*?);]{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | local $_ = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | /^amp$/i ? "&" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition0%0/6
/^#(\d+)$/ and $latin
/^#x([0-9a-f]+)$/i and $latin
MC/DC0%0/2
/^#(\d+)$/ and $latin
/^#(\d+)$/
$latin
MC/DC0%0/2
/^#x([0-9a-f]+)$/i and $latin
/^#x([0-9a-f]+)$/i
$latin
Truth table0%0/3
A and B
A= /^#(\d+)$/B= $latin
Truth table0%0/3
A and B
A= /^#x([0-9a-f]+)$/iB= $latin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | /^quot$/i ? '"' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | /^gt$/i ? ">" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | /^lt$/i ? "<" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | /^#(\d+)$/ && $latin ? chr($1) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | /^#x([0-9a-f]+)$/i && $latin ? chr(hex($1)) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | }gex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||