| 1 | 6 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | class Azure::SDK::Storage::Tables::EntityContinuation { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use MIME::Base64 qw(decode_base64 encode_base64); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use constant MAX_TOKEN_LENGTH => 16 * 1024; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub encode ( $class, $partition_key, $row_key ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode: called CC=6 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | return undef unless defined $partition_key || defined $row_key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $partition_key or defined $row_key
MC/DC50%1/2
defined $partition_key or defined $row_key
defined $partition_key
defined $row_key
Truth table66%2/3
A or B
A= defined $partition_keyB= defined $row_key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | _validate_part('partition key', $partition_key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | _validate_part('row key', $row_key) if defined $row_key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | croak 'Table entity continuation row key requires a partition key' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $row_key and not defined $partition_key
MC/DC0%0/2
defined $row_key and not defined $partition_key
defined $row_key
not defined $partition_key
Truth table33%1/3
A and not(B)
A= defined $row_keyB= not defined $partition_key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | if defined $row_key && !defined $partition_key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my $json = JSON::PP->new->utf8->canonical->encode({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | p => $partition_key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | r => $row_key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my $token = encode_base64($json, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | $token =~ tr{+/}{-_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | $token =~ s/=+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | return $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | sub decode ( $class, $token ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode: called CC=13 SCAR=31.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | croak 'Table entity continuation token is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $token and not ref $token and length $token
defined $token and not ref $token
MC/DC0%0/3
defined $token and not ref $token and length $token
defined $token
not ref $token
length $token
Truth table25%1/4
A and not(B) and C
A= defined $tokenB= not ref $tokenC= length $token
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | unless defined $token && !ref $token && length $token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | croak 'Table entity continuation token is too long' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | if length($token) > MAX_TOKEN_LENGTH; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | croak 'Table entity continuation token is malformed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | unless $token =~ /\A[A-Za-z0-9_-]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | my $encoded = $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | $encoded =~ tr{-_}{+/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | $encoded .= '=' x ((4 - length($encoded) % 4) % 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | my $document = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | JSON::PP->new->utf8->decode(decode_base64($encoded)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | croak 'Table entity continuation token is malformed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | if $@ || ref $document ne 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | || grep { $_ ne 'p' && $_ ne 'r' } keys $document->%*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
$@ or ref $document ne "HASH" or grep {$_ ne "p" and $_ ne "r";} keys %$document
$@ or ref $document ne "HASH"
$_ ne 'p' && $_ ne 'r'
MC/DC0%0/3
$@ or ref $document ne "HASH" or grep {$_ ne "p" and $_ ne "r";} keys %$document
$@
ref $document ne "HASH"
grep {$_ ne "p" and $_ ne "r";} keys %$document
MC/DC0%0/2
$_ ne 'p' && $_ ne 'r'
$_ ne 'p'
$_ ne 'r'
Truth table25%1/4
A or B or C
A= $@B= ref $document ne "HASH"C= grep {$_ ne "p" and $_ ne "r";} keys %$document
Truth table66%2/3
A && B
A= $_ ne 'p'B= $_ ne 'r'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | _validate_part('partition key', $document->{p}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | _validate_part('row key', $document->{r}) if defined $document->{r}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | croak 'Table entity continuation row key requires a partition key' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | if defined $document->{r} && !defined $document->{p}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $document->{"r"} and not defined $document->{"p"}
MC/DC0%0/2
defined $document->{"r"} and not defined $document->{"p"}
defined $document->{"r"}
not defined $document->{"p"}
Truth table33%1/3
A and not(B)
A= defined $document->{"r"}B= not defined $document->{"p"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | return ($document->{p}, $document->{r}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | ▶ | sub _validate_part ( $label, $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_part: called CC=4 SCAR=16.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | croak "Table entity continuation $label is required" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $value and not ref $value
MC/DC0%0/2
defined $value and not ref $value
defined $value
not ref $value
Truth table33%1/3
A and not(B)
A= defined $valueB= not ref $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | unless defined $value && !ref $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | ▶ | croak "Table entity continuation $label contains control characters" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | if $value =~ /[\x00-\x1f\x7f]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||