« blib/lib/WebDyne/Cloudflare/Hyperdrive.pm
↑ Summary
lib/WebDyne/Cloudflare/DurableObject/Context.pm »
| 1 | package WebDyne::Cloudflare; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Encode qw(decode FB_CROAK); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | our $VERSION='0.005'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1395 | ▶ | sub json_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
json_value: called CC=12 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1395 | my ($value_ref, $seen_hr)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1395 | ▶ | if (!ref($value_ref)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1173 | ▶ | return decode('UTF-8', $value_ref, FB_CROAK) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $value_ref and not utf8::is_utf8($value_ref) and $value_ref =~ /[\x80-\xff]/u
defined $value_ref and not utf8::is_utf8($value_ref)
MC/DC100%3/3
defined $value_ref and not utf8::is_utf8($value_ref) and $value_ref =~ /[\x80-\xff]/u
defined $value_ref
not utf8::is_utf8($value_ref)
$value_ref =~ /[\x80-\xff]/u
Truth table100%4/4
A and not(B) and C
A= defined $value_refB= not utf8::is_utf8($value_ref)C= $value_ref =~ /[\x80-\xff]/u
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | if (defined($value_ref)&&!utf8::is_utf8($value_ref)&&($value_ref=~/[\x80-\xff]/)); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 1156 | return $value_ref; | |||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 222 | my $type=ref($value_ref); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 222 | ▶ | return $value_ref unless (($type eq 'HASH')||($type eq 'ARRAY')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type eq "HASH" or $type eq "ARRAY"
MC/DC100%2/2
$type eq "HASH" or $type eq "ARRAY"
$type eq "HASH"
$type eq "ARRAY"
Truth table100%3/3
A or B
A= $type eq "HASH"B= $type eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | # Normalize a copy, preserving numeric flags and rejecting cyclic input. | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 208 | ▶ | $seen_hr={} unless $seen_hr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 208 | my $address=refaddr($value_ref); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 208 | ▶ | die "Cloudflare request contains a circular reference\n" if $seen_hr->{$address}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 207 | local $seen_hr->{$address}=1; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 207 | ▶ | return [map { json_value($_, $seen_hr) } @{$value_ref}] if ($type eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 129 | my %value; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 129 | foreach my $key (keys(%{$value_ref})) { | |||||||||||||||||||||||||||||||||||||||||
| 30 | 594 | my $name=json_value($key); | |||||||||||||||||||||||||||||||||||||||||
| 31 | 594 | ▶ | die "Cloudflare request contains duplicate UTF-8 keys\n" if exists($value{$name}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 593 | $value{$name}=json_value($value_ref->{$key}, $seen_hr); | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 125 | return \%value; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||