| 1 | package CGI::Simple::Cookie; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # Original version Copyright 1995-1999, Lincoln D. Stein. All rights reserved. | ||||||||||||||||||||||||||||
| 4 | # It may be used and modified freely, but I do request that this copyright | ||||||||||||||||||||||||||||
| 5 | # notice remain attached to the file. You may modify this module as you | ||||||||||||||||||||||||||||
| 6 | # wish, but if you redistribute a modified version, please attach a note | ||||||||||||||||||||||||||||
| 7 | # listing the modifications you have made. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # This version Copyright 2001, Dr James Freeman. All rights reserved. | ||||||||||||||||||||||||||||
| 10 | # Renamed, strictified, and generally hacked code. Now 30% shorter. | ||||||||||||||||||||||||||||
| 11 | # Interface remains identical and passes all original CGI::Cookie tests | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | $VERSION = '1.282'; | |||||||||||||||||||||||||||
| 17 | 2 | ▶ | use CGI::Simple::Util qw(rearrange unescape escape); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use overload '""' => \&as_string, 'cmp' => \&compare, 'fallback' => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # fetch a list of cookies from the environment and return as a hash. | ||||||||||||||||||||||||||||
| 21 | # the cookies are parsed as normal escaped URL data. | ||||||||||||||||||||||||||||
| 22 | 5 | ▶ | sub fetch { | ||||||||||||||||||||||||||
|
Subroutine
fetch: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 24 | 5 | ▶ | my $raw_cookie = $ENV{HTTP_COOKIE} || $ENV{COOKIE}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$ENV{'HTTP_COOKIE'} || $ENV{'COOKIE'}
MC/DC100%2/2
$ENV{'HTTP_COOKIE'} || $ENV{'COOKIE'}
$ENV{'HTTP_COOKIE'}
$ENV{'COOKIE'}
Truth table100%3/3
A || B
A= $ENV{'HTTP_COOKIE'}B= $ENV{'COOKIE'}
| |||||||||||||||||||||||||||||
| 25 | 5 | ▶ | return () unless $raw_cookie; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 3 | return $self->parse( $raw_cookie ); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 7 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=7 SCAR=19.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 7 | my ( $self, $raw_cookie ) = @_; | |||||||||||||||||||||||||||
| 31 | 7 | ▶ | return () unless $raw_cookie; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 7 | my %results; | |||||||||||||||||||||||||||
| 33 | 7 | my @pairs = split "[;,] ?", $raw_cookie; | |||||||||||||||||||||||||||
| 34 | 7 | for my $pair ( @pairs ) { | |||||||||||||||||||||||||||
| 35 | # trim leading trailing whitespace | ||||||||||||||||||||||||||||
| 36 | 25 | $pair =~ s/^\s+//; | |||||||||||||||||||||||||||
| 37 | 25 | $pair =~ s/\s+$//; | |||||||||||||||||||||||||||
| 38 | 25 | my ( $key, $value ) = split( "=", $pair, 2 ); | |||||||||||||||||||||||||||
| 39 | 25 | ▶ | next if !defined( $value ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 25 | my @values = (); | |||||||||||||||||||||||||||
| 41 | 25 | ▶ | if ( $value ne '' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 25 | @values = map unescape( $_ ), split( /[&;]/, $value . '&dmy' ); | |||||||||||||||||||||||||||
| 43 | 25 | pop @values; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 25 | $key = unescape( $key ); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # A bug in Netscape can cause several cookies with same name to | ||||||||||||||||||||||||||||
| 48 | # appear. The FIRST one in HTTP_COOKIE is the most recent version. | ||||||||||||||||||||||||||||
| 49 | 25 | ▶ | $results{$key} ||= $self->new( -name => $key, -value => \@values ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$results{$key} ||= $self->new("-name", $key, "-value", \@values)
MC/DC0%0/2
$results{$key} ||= $self->new("-name", $key, "-value", \@values)
$results{$key}
$self->new("-name", $key, "-value", \@values)
Truth table33%1/3
A ||= B
A= $results{$key}B= $self->new("-name", $key, "-value", \@values)
| |||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 7 | ▶ | return wantarray ? %results : \%results; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # fetch a list of cookies from the environment and return as a hash. | ||||||||||||||||||||||||||||
| 55 | # the cookie values are not unescaped or altered in any way. | ||||||||||||||||||||||||||||
| 56 | 5 | ▶ | sub raw_fetch { | ||||||||||||||||||||||||||
|
Subroutine
raw_fetch: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 5 | ▶ | my $raw_cookie = $ENV{HTTP_COOKIE} || $ENV{COOKIE}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$ENV{'HTTP_COOKIE'} || $ENV{'COOKIE'}
MC/DC100%2/2
$ENV{'HTTP_COOKIE'} || $ENV{'COOKIE'}
$ENV{'HTTP_COOKIE'}
$ENV{'COOKIE'}
Truth table100%3/3
A || B
A= $ENV{'HTTP_COOKIE'}B= $ENV{'COOKIE'}
| |||||||||||||||||||||||||||||
| 58 | 5 | ▶ | return () unless $raw_cookie; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 3 | my %results; | |||||||||||||||||||||||||||
| 60 | 3 | my @pairs = split "; ?", $raw_cookie; | |||||||||||||||||||||||||||
| 61 | 3 | for my $pair ( @pairs ) { | |||||||||||||||||||||||||||
| 62 | 10 | $pair =~ s/^\s+|\s+$//; # trim leading trailing whitespace | |||||||||||||||||||||||||||
| 63 | 10 | my ( $key, $value ) = split "=", $pair; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # fixed bug that does not allow 0 as a cookie value thanks Jose Mico | ||||||||||||||||||||||||||||
| 66 | # $value ||= 0; | ||||||||||||||||||||||||||||
| 67 | 10 | ▶ | $value = defined $value ? $value : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 10 | $results{$key} = $value; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 3 | ▶ | return wantarray ? %results : \%results; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 44 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=14 SCAR=26.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 44 | my ( $class, @params ) = @_; | |||||||||||||||||||||||||||
| 75 | 44 | ▶ | $class = ref( $class ) || $class; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 76 | my ( | ||||||||||||||||||||||||||||
| 77 | 44 | $name, $value, $path, $domain, | |||||||||||||||||||||||||||
| 78 | $secure, $expires, $max_age, $httponly, $samesite, | ||||||||||||||||||||||||||||
| 79 | $priority, $partitioned | ||||||||||||||||||||||||||||
| 80 | ) | ||||||||||||||||||||||||||||
| 81 | = rearrange( | ||||||||||||||||||||||||||||
| 82 | [ | ||||||||||||||||||||||||||||
| 83 | 'NAME', [ 'VALUE', 'VALUES' ], | ||||||||||||||||||||||||||||
| 84 | 'PATH', 'DOMAIN', | ||||||||||||||||||||||||||||
| 85 | 'SECURE', 'EXPIRES', | ||||||||||||||||||||||||||||
| 86 | 'MAX-AGE', 'HTTPONLY', 'SAMESITE', | ||||||||||||||||||||||||||||
| 87 | 'PRIORITY', 'PARTITIONED', | ||||||||||||||||||||||||||||
| 88 | ], | ||||||||||||||||||||||||||||
| 89 | @params | ||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||
| 91 | 44 | ▶ | return undef unless defined $name and defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and defined $value
MC/DC0%0/2
defined $name and defined $value
defined $name
defined $value
Truth table33%1/3
A and B
A= defined $nameB= defined $value
| |||||||||||||||||||||||||||||
| 92 | 44 | my $self = {}; | |||||||||||||||||||||||||||
| 93 | 44 | bless $self, $class; | |||||||||||||||||||||||||||
| 94 | 44 | $self->name( $name ); | |||||||||||||||||||||||||||
| 95 | 44 | $self->value( $value ); | |||||||||||||||||||||||||||
| 96 | 44 | ▶ | $path ||= "/"; | ||||||||||||||||||||||||||
|
Condition100%2/2
$path ||= "/"
MC/DC100%1/1
$path ||= "/"
$path
Truth table100%2/2
A
A= $path
| |||||||||||||||||||||||||||||
| 97 | 44 | ▶ | $self->path( $path ) if defined $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 44 | ▶ | $self->domain( $domain ) if defined $domain; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 44 | ▶ | $self->secure( $secure ) if defined $secure; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 44 | ▶ | $self->expires( $expires ) if defined $expires; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 44 | ▶ | $self->max_age( $max_age ) if defined $max_age; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 44 | ▶ | $self->httponly( $httponly ) if defined $httponly; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 44 | ▶ | $self->samesite( $samesite ) if defined $samesite; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 44 | ▶ | $self->priority( $priority ) if defined $priority; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 44 | ▶ | $self->partitioned( $partitioned ) if defined $partitioned; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 44 | return $self; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 42 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 110 | 42 | my $self = shift; | |||||||||||||||||||||||||||
| 111 | 42 | ▶ | return "" unless $self->name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 42 | my $name = escape( $self->name ); | |||||||||||||||||||||||||||
| 113 | 42 | my $value = join "&", map { escape( $_ ) } $self->value; | |||||||||||||||||||||||||||
| 114 | 42 | my @cookie = ( "$name=$value" ); | |||||||||||||||||||||||||||
| 115 | 42 | ▶ | push @cookie, "domain=" . $self->domain if $self->domain; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 42 | ▶ | push @cookie, "path=" . $self->path if $self->path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 42 | ▶ | push @cookie, "expires=" . $self->expires if $self->expires; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 42 | ▶ | push @cookie, "max-age=" . $self->max_age if $self->max_age; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 42 | ▶ | push @cookie, "secure" if $self->secure; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 42 | ▶ | push @cookie, "HttpOnly" if $self->httponly; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 42 | ▶ | push @cookie, "SameSite=" . $self->samesite if $self->samesite; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 42 | ▶ | push @cookie,"Priority=".$self->priority if $self->priority; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 42 | ▶ | push @cookie,"Partitioned" if $self->partitioned; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 42 | return join "; ", @cookie; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 8 | ▶ | sub compare { | ||||||||||||||||||||||||||
|
Subroutine
compare: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 128 | 8 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 129 | 8 | return "$self" cmp $value; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | # accessors subs | ||||||||||||||||||||||||||||
| 133 | 135 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 134 | 135 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||
| 135 | 135 | ▶ | $self->{'name'} = $name if defined $name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 135 | return $self->{'name'}; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 109 | ▶ | sub value { | ||||||||||||||||||||||||||
|
Subroutine
value: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 140 | 109 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||
| 141 | 109 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | my @values | ||||||||||||||||||||||||||||
| 143 | 45 | ▶ | = ref $value eq 'ARRAY' ? @$value | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 144 | : ref $value eq 'HASH' ? %$value | ||||||||||||||||||||||||||||
| 145 | : ( $value ); | ||||||||||||||||||||||||||||
| 146 | 45 | $self->{'value'} = [@values]; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 109 | ▶ | return wantarray ? @{ $self->{'value'} } : $self->{'value'}->[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 87 | ▶ | sub domain { | ||||||||||||||||||||||||||
|
Subroutine
domain: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 152 | 87 | my ( $self, $domain ) = @_; | |||||||||||||||||||||||||||
| 153 | 87 | ▶ | $self->{'domain'} = $domain if defined $domain; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 87 | return $self->{'domain'}; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 56 | ▶ | sub secure { | ||||||||||||||||||||||||||
|
Subroutine
secure: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | 56 | my ( $self, $secure ) = @_; | |||||||||||||||||||||||||||
| 159 | 56 | ▶ | $self->{'secure'} = $secure if defined $secure; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 56 | return $self->{'secure'}; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 89 | ▶ | sub expires { | ||||||||||||||||||||||||||
|
Subroutine
expires: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 89 | my ( $self, $expires ) = @_; | |||||||||||||||||||||||||||
| 165 | 89 | ▶ | $self->{'expires'} = CGI::Simple::Util::expires( $expires, 'cookie' ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | if defined $expires; | ||||||||||||||||||||||||||||
| 167 | 89 | return $self->{'expires'}; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 65 | ▶ | sub max_age { | ||||||||||||||||||||||||||
|
Subroutine
max_age: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 171 | 65 | my ( $self, $max_age ) = @_; | |||||||||||||||||||||||||||
| 172 | 65 | ▶ | $self->{'max-age'} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | = CGI::Simple::Util::_expire_calc( $max_age ) - time() | ||||||||||||||||||||||||||||
| 174 | if defined $max_age; | ||||||||||||||||||||||||||||
| 175 | 65 | return $self->{'max-age'}; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 135 | ▶ | sub path { | ||||||||||||||||||||||||||
|
Subroutine
path: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 179 | 135 | my ( $self, $path ) = @_; | |||||||||||||||||||||||||||
| 180 | 135 | ▶ | $self->{'path'} = $path if defined $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 135 | return $self->{'path'}; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 56 | ▶ | sub httponly { | ||||||||||||||||||||||||||
|
Subroutine
httponly: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 56 | my ( $self, $httponly ) = @_; | |||||||||||||||||||||||||||
| 186 | 56 | ▶ | $self->{'httponly'} = $httponly if defined $httponly; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 56 | return $self->{'httponly'}; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 46 | ▶ | sub partitioned { # Partitioned | ||||||||||||||||||||||||||
|
Subroutine
partitioned: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 191 | 46 | my ( $self, $partitioned ) = @_; | |||||||||||||||||||||||||||
| 192 | 46 | ▶ | $self->{'partitioned'} = $partitioned if defined $partitioned; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 46 | return $self->{'partitioned'}; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 2 | my %_legal_samesite = ( Strict => 1, Lax => 1, None => 1 ); | |||||||||||||||||||||||||||
| 197 | 63 | ▶ | sub samesite { | ||||||||||||||||||||||||||
|
Subroutine
samesite: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 198 | 63 | my $self = shift; | |||||||||||||||||||||||||||
| 199 | 63 | ▶ | my $samesite = ucfirst lc +shift if @_; # Normalize casing. | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 63 | ▶ | $self->{'samesite'} = $samesite if $samesite and $_legal_samesite{$samesite}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$samesite and $_legal_samesite{$samesite}
MC/DC50%1/2
$samesite and $_legal_samesite{$samesite}
$samesite
$_legal_samesite{$samesite}
Truth table66%2/3
A and B
A= $samesiteB= $_legal_samesite{$samesite}
| |||||||||||||||||||||||||||||
| 201 | 63 | return $self->{'samesite'}; | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 2 | my %_legal_priority = ( Low => 1, Medium => 1, High => 1 ); | |||||||||||||||||||||||||||
| 205 | 56 | ▶ | sub priority { | ||||||||||||||||||||||||||
|
Subroutine
priority: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 206 | 56 | my $self = shift; | |||||||||||||||||||||||||||
| 207 | 56 | ▶ | my $priority = ucfirst lc +shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 56 | ▶ | if ($priority && $_legal_priority{$priority}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$priority and $_legal_priority{$priority}
MC/DC50%1/2
$priority and $_legal_priority{$priority}
$priority
$_legal_priority{$priority}
Truth table66%2/3
A and B
A= $priorityB= $_legal_priority{$priority}
| |||||||||||||||||||||||||||||
| 209 | 2 | $self->{'priority'} = $priority; | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | 56 | return $self->{'priority'}; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 2 | 1; | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | __END__ | ||||||||||||||||||||||||||||