| 1 | package Net::Blossom::_CashuPaymentRequest; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strictures 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use B (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use CBOR::Free::Decoder (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Encode qw(decode FB_CROAK); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use MIME::Base64 qw(decode_base64); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Net::Blossom::_Bech32 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Net::Blossom::_URL (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | my $BECH32M_CHECKSUM = 0x2bc830a3; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 53 | ▶ | sub valid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valid: called CC=6 SCAR=19.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 53 | my ($payload) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 53 | ▶ | return 0 unless defined $payload && !ref($payload) && length $payload; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $payload and not ref $payload and length $payload
defined $payload and not ref $payload
MC/DC0%0/3
defined $payload and not ref $payload and length $payload
defined $payload
not ref $payload
length $payload
Truth table25%1/4
A and not(B) and C
A= defined $payloadB= not ref $payloadC= length $payload
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 53 | ▶ | return _valid_cbor(substr($payload, 5)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | if substr($payload, 0, 5) =~ /\Acreqa\z/i; | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 37 | ▶ | return _valid_tlv($payload) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | if substr($payload, 0, 6) =~ /\Acreqb1\z/i; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 16 | ▶ | sub _valid_cbor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_cbor: called CC=7 SCAR=19.8
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 16 | my ($encoded) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 16 | my $bytes = _decode_base64url($encoded); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 16 | ▶ | return 0 unless defined $bytes && length $bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $bytes and length $bytes
MC/DC0%0/2
defined $bytes and length $bytes
defined $bytes
length $bytes
Truth table33%1/3
A and B
A= defined $bytesB= length $bytes
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 16 | my (@warnings, $request); | |||||||||||||||||||||||||||||||||||||||||
| 31 | 16 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 32 | 16 | ▶ | local $SIG{__WARN__} = sub { push @warnings, @_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 16 | my $decoder = CBOR::Free::Decoder->new(); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 16 | $decoder->reject_duplicate_keys(); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 16 | $request = $decoder->decode($bytes); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 37 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 16 | ▶ | return 0 unless $ok && !@warnings && ref($request) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$ok and not @warnings and ref $request eq "HASH"
$ok and not @warnings
MC/DC66%2/3
$ok and not @warnings and ref $request eq "HASH"
$ok
not @warnings
ref $request eq "HASH"
Truth table75%3/4
A and not(B) and C
A= $okB= not @warningsC= ref $request eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 14 | ▶ | return 0 if grep { !_text($_) } keys %$request; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 14 | return _valid_request($request); | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 36 | ▶ | sub _valid_tlv { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_tlv: called CC=30 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 36 | my ($payload) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 36 | my ($hrp, $words) = Net::Blossom::_Bech32::decode($payload, $BECH32M_CHECKSUM); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 36 | ▶ | return 0 unless defined $hrp && $hrp eq 'creqb'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $hrp and $hrp eq "creqb"
MC/DC50%1/2
defined $hrp and $hrp eq "creqb"
defined $hrp
$hrp eq "creqb"
Truth table66%2/3
A and B
A= defined $hrpB= $hrp eq "creqb"
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 33 | my $bytes = Net::Blossom::_Bech32::convert_5_to_8($words); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 33 | ▶ | return 0 unless defined $bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 33 | my $entries = _tlv_entries($bytes); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 33 | ▶ | return 0 unless defined $entries; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 31 | my @amount = grep { $_->[0] == 0x02 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 31 | ▶ | return 0 unless @amount == 1 && length($amount[0][1]) == 8; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@amount == 1 and length $amount[0][1] == 8
MC/DC100%2/2
@amount == 1 and length $amount[0][1] == 8
@amount == 1
length $amount[0][1] == 8
Truth table100%3/3
A and B
A= @amount == 1B= length $amount[0][1] == 8
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 28 | ▶ | return 0 unless grep { $_ ne "\0" } split //, $amount[0][1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 27 | my @unit = grep { $_->[0] == 0x03 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 27 | ▶ | return 0 unless @unit == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 25 | ▶ | if ($unit[0][1] ne "\0") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my $unit = _utf8($unit[0][1]); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | return 0 unless defined $unit && length $unit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $unit and length $unit
MC/DC0%0/2
defined $unit and length $unit
defined $unit
length $unit
Truth table66%2/3
A and B
A= defined $unitB= length $unit
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 23 | my @mints = grep { $_->[0] == 0x05 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 23 | ▶ | return 0 unless @mints; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 22 | for my $entry (@mints) { | |||||||||||||||||||||||||||||||||||||||||
| 67 | 23 | my $mint = _utf8($entry->[1]); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 23 | ▶ | return 0 unless defined $mint && Net::Blossom::_URL::http_base_url($mint); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $mint and Net::Blossom::_URL::http_base_url($mint)
MC/DC100%2/2
defined $mint and Net::Blossom::_URL::http_base_url($mint)
defined $mint
Net::Blossom::_URL::http_base_url($mint)
Truth table100%3/3
A and B
A= defined $mintB= Net::Blossom::_URL::http_base_url($mint)
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 20 | my @id = grep { $_->[0] == 0x01 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 20 | ▶ | return 0 if @id > 1 || @id && !defined _utf8($id[0][1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@id > 1 or @id and not defined _utf8($id[0][1])
@id and not defined _utf8($id[0][1])
MC/DC100%3/3
@id > 1 or @id and not defined _utf8($id[0][1])
@id > 1
@id
not defined _utf8($id[0][1])
Truth table100%4/4
A or B and not(C)
A= @id > 1B= @idC= not defined _utf8($id[0][1])
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 18 | my @single_use = grep { $_->[0] == 0x04 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 18 | ▶ | return 0 if @single_use > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 17 | ▶ | return 0 if @single_use | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@single_use and length $single_use[0][1] != 1 || ord $single_use[0][1] > 1
length $single_use[0][1] != 1 or ord $single_use[0][1] > 1
MC/DC100%3/3
@single_use and length $single_use[0][1] != 1 || ord $single_use[0][1] > 1
@single_use
length $single_use[0][1] != 1
ord $single_use[0][1] > 1
Truth table100%4/4
A and B or C
A= @single_useB= length $single_use[0][1] != 1C= ord $single_use[0][1] > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | && (length($single_use[0][1]) != 1 || ord($single_use[0][1]) > 1); | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 15 | my @description = grep { $_->[0] == 0x06 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 15 | ▶ | return 0 if @description > 1 || @description && !defined _utf8($description[0][1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@description > 1 or @description and not defined _utf8($description[0][1])
@description and not defined _utf8($description[0][1])
MC/DC100%3/3
@description > 1 or @description and not defined _utf8($description[0][1])
@description > 1
@description
not defined _utf8($description[0][1])
Truth table100%4/4
A or B and not(C)
A= @description > 1B= @descriptionC= not defined _utf8($description[0][1])
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 13 | my @transport = grep { $_->[0] == 0x07 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 13 | ▶ | return 0 if grep { !_valid_tlv_transport($_->[1]) } @transport; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 9 | my @nut10 = grep { $_->[0] == 0x08 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 9 | ▶ | return 0 if @nut10 > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | ▶ | return 0 if @nut10 && !_valid_tlv_nut10($nut10[0][1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@nut10 and not _valid_tlv_nut10($nut10[0][1])
MC/DC100%2/2
@nut10 and not _valid_tlv_nut10($nut10[0][1])
@nut10
not _valid_tlv_nut10($nut10[0][1])
Truth table100%3/3
A and not(B)
A= @nut10B= not _valid_tlv_nut10($nut10[0][1])
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 14 | ▶ | sub _valid_request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_request: called CC=24 SCAR=34.9
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 14 | my ($request) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 14 | ▶ | return 0 unless exists $request->{a} && _integer($request->{a}) && $request->{a} > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $request->{"a"} and _integer($request->{"a"}) and $request->{"a"} > 0
exists $request->{"a"} and _integer($request->{"a"})
MC/DC0%0/3
exists $request->{"a"} and _integer($request->{"a"}) and $request->{"a"} > 0
exists $request->{"a"}
_integer($request->{"a"})
$request->{"a"} > 0
Truth table25%1/4
A and B and C
A= exists $request->{"a"}B= _integer($request->{"a"})C= $request->{"a"} > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 14 | ▶ | return 0 unless exists $request->{u} && _text($request->{u}) && length $request->{u}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $request->{"u"} and _text($request->{"u"}) and length $request->{"u"}
exists $request->{"u"} and _text($request->{"u"})
MC/DC0%0/3
exists $request->{"u"} and _text($request->{"u"}) and length $request->{"u"}
exists $request->{"u"}
_text($request->{"u"})
length $request->{"u"}
Truth table25%1/4
A and B and C
A= exists $request->{"u"}B= _text($request->{"u"})C= length $request->{"u"}
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 14 | ▶ | return 0 unless exists $request->{m} && ref($request->{m}) eq 'ARRAY' && @{$request->{m}}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $request->{"m"} and ref $request->{"m"} eq "ARRAY" and @{$request->{"m"};}
exists $request->{"m"} and ref $request->{"m"} eq "ARRAY"
MC/DC0%0/3
exists $request->{"m"} and ref $request->{"m"} eq "ARRAY" and @{$request->{"m"};}
exists $request->{"m"}
ref $request->{"m"} eq "ARRAY"
@{$request->{"m"};}
Truth table25%1/4
A and B and C
A= exists $request->{"m"}B= ref $request->{"m"} eq "ARRAY"C= @{$request->{"m"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 14 | for my $mint (@{$request->{m}}) { | |||||||||||||||||||||||||||||||||||||||||
| 98 | 14 | ▶ | return 0 unless _text($mint) && Net::Blossom::_URL::http_base_url($mint); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
_text($mint) and Net::Blossom::_URL::http_base_url($mint)
MC/DC0%0/2
_text($mint) and Net::Blossom::_URL::http_base_url($mint)
_text($mint)
Net::Blossom::_URL::http_base_url($mint)
Truth table33%1/3
A and B
A= _text($mint)B= Net::Blossom::_URL::http_base_url($mint)
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 14 | ▶ | return 0 if exists $request->{i} && !_text($request->{i}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $request->{"i"} and not _text($request->{"i"})
MC/DC100%2/2
exists $request->{"i"} and not _text($request->{"i"})
exists $request->{"i"}
not _text($request->{"i"})
Truth table100%3/3
A and not(B)
A= exists $request->{"i"}B= not _text($request->{"i"})
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 13 | ▶ | return 0 if exists $request->{s} && !_boolean($request->{s}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $request->{"s"} and not _boolean($request->{"s"})
MC/DC100%2/2
exists $request->{"s"} and not _boolean($request->{"s"})
exists $request->{"s"}
not _boolean($request->{"s"})
Truth table100%3/3
A and not(B)
A= exists $request->{"s"}B= not _boolean($request->{"s"})
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 12 | ▶ | return 0 if exists $request->{d} && !_text($request->{d}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $request->{"d"} and not _text($request->{"d"})
MC/DC100%2/2
exists $request->{"d"} and not _text($request->{"d"})
exists $request->{"d"}
not _text($request->{"d"})
Truth table100%3/3
A and not(B)
A= exists $request->{"d"}B= not _text($request->{"d"})
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 11 | ▶ | if (exists $request->{t}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | ▶ | return 0 unless ref($request->{t}) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | ▶ | return 0 if grep { !_valid_cbor_transport($_) } @{$request->{t}}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | ▶ | return 0 if exists $request->{nut10} && !_valid_cbor_nut10($request->{nut10}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $request->{"nut10"} and not _valid_cbor_nut10($request->{"nut10"})
MC/DC100%2/2
exists $request->{"nut10"} and not _valid_cbor_nut10($request->{"nut10"})
exists $request->{"nut10"}
not _valid_cbor_nut10($request->{"nut10"})
Truth table100%3/3
A and not(B)
A= exists $request->{"nut10"}B= not _valid_cbor_nut10($request->{"nut10"})
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | ▶ | sub _valid_cbor_transport { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_cbor_transport: called CC=13 SCAR=31.2
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | my ($transport) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 3 | ▶ | return 0 unless ref($transport) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | ▶ | return 0 if grep { !_text($_) } keys %$transport; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | return 0 unless exists $transport->{t} && _text($transport->{t}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $transport->{"t"} and _text($transport->{"t"})
MC/DC0%0/2
exists $transport->{"t"} and _text($transport->{"t"})
exists $transport->{"t"}
_text($transport->{"t"})
Truth table33%1/3
A and B
A= exists $transport->{"t"}B= _text($transport->{"t"})
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | return 0 unless exists $transport->{a} && _text($transport->{a}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $transport->{"a"} and _text($transport->{"a"})
MC/DC50%1/2
exists $transport->{"a"} and _text($transport->{"a"})
exists $transport->{"a"}
_text($transport->{"a"})
Truth table66%2/3
A and B
A= exists $transport->{"a"}B= _text($transport->{"a"})
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | return 1 unless exists $transport->{g}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | return 0 unless ref($transport->{g}) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | for my $tag (@{$transport->{g}}) { | |||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | return 0 unless ref($tag) eq 'ARRAY' && @$tag >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $tag eq "ARRAY" and @$tag >= 2
MC/DC0%0/2
ref $tag eq "ARRAY" and @$tag >= 2
ref $tag eq "ARRAY"
@$tag >= 2
Truth table33%1/3
A and B
A= ref $tag eq "ARRAY"B= @$tag >= 2
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return 0 if grep { !_text($_) } @$tag; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 7 | ▶ | sub _valid_cbor_nut10 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_cbor_nut10: called CC=16 SCAR=28.5
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 7 | my ($nut10) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 7 | ▶ | return 0 unless ref($nut10) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 6 | ▶ | return 0 if grep { !_text($_) } keys %$nut10; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 6 | ▶ | return 0 unless exists $nut10->{k} && _text($nut10->{k}) && length $nut10->{k}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $nut10->{"k"} and _text($nut10->{"k"}) and length $nut10->{"k"}
exists $nut10->{"k"} and _text($nut10->{"k"})
MC/DC33%1/3
exists $nut10->{"k"} and _text($nut10->{"k"}) and length $nut10->{"k"}
exists $nut10->{"k"}
_text($nut10->{"k"})
length $nut10->{"k"}
Truth table50%2/4
A and B and C
A= exists $nut10->{"k"}B= _text($nut10->{"k"})C= length $nut10->{"k"}
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | ▶ | return 0 unless exists $nut10->{d} && _text($nut10->{d}) && length $nut10->{d}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $nut10->{"d"} and _text($nut10->{"d"}) and length $nut10->{"d"}
exists $nut10->{"d"} and _text($nut10->{"d"})
MC/DC33%1/3
exists $nut10->{"d"} and _text($nut10->{"d"}) and length $nut10->{"d"}
exists $nut10->{"d"}
_text($nut10->{"d"})
length $nut10->{"d"}
Truth table50%2/4
A and B and C
A= exists $nut10->{"d"}B= _text($nut10->{"d"})C= length $nut10->{"d"}
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | ▶ | return 1 unless exists $nut10->{t}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | ▶ | return 0 unless ref($nut10->{t}) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | for my $tag (@{$nut10->{t}}) { | |||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | ▶ | return 0 unless ref($tag) eq 'ARRAY' && @$tag == 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $tag eq "ARRAY" and @$tag == 2
MC/DC50%1/2
ref $tag eq "ARRAY" and @$tag == 2
ref $tag eq "ARRAY"
@$tag == 2
Truth table66%2/3
A and B
A= ref $tag eq "ARRAY"B= @$tag == 2
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | return 0 unless _text($tag->[0]) && _text($tag->[1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
_text($tag->[0]) and _text($tag->[1])
MC/DC50%1/2
_text($tag->[0]) and _text($tag->[1])
_text($tag->[0])
_text($tag->[1])
Truth table66%2/3
A and B
A= _text($tag->[0])B= _text($tag->[1])
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | sub _valid_tlv_nut10 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_tlv_nut10: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 3 | my ($bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 3 | my $entries = _tlv_entries($bytes); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 3 | ▶ | return 0 unless defined $entries; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | my @kind = grep { $_->[0] == 0x01 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | my @data = grep { $_->[0] == 0x02 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 3 | ▶ | return 0 unless @kind == 1 && length($kind[0][1]) == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@kind == 1 and length $kind[0][1] == 1
MC/DC0%0/2
@kind == 1 and length $kind[0][1] == 1
@kind == 1
length $kind[0][1] == 1
Truth table33%1/3
A and B
A= @kind == 1B= length $kind[0][1] == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | return 0 unless @data == 1 && defined _utf8($data[0][1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@data == 1 and defined _utf8($data[0][1])
MC/DC50%1/2
@data == 1 and defined _utf8($data[0][1])
@data == 1
defined _utf8($data[0][1])
Truth table66%2/3
A and B
A= @data == 1B= defined _utf8($data[0][1])
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | ▶ | return 0 if grep { $_->[0] == 0x03 && !_valid_tag_tuple($_->[1]) } @$entries; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_->[0] == 3 && !_valid_tag_tuple($_->[1])
MC/DC100%2/2
$_->[0] == 3 && !_valid_tag_tuple($_->[1])
$_->[0] == 3
!_valid_tag_tuple($_->[1])
Truth table100%3/3
A && not(B)
A= $_->[0] == 3B= !_valid_tag_tuple($_->[1])
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 6 | ▶ | sub _valid_tlv_transport { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_tlv_transport: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 6 | my ($bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | my $entries = _tlv_entries($bytes); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | ▶ | return 0 unless defined $entries; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 6 | my @kind = grep { $_->[0] == 0x01 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 6 | my @target = grep { $_->[0] == 0x02 } @$entries; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 6 | ▶ | return 0 unless @kind == 1 && length($kind[0][1]) == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@kind == 1 and length $kind[0][1] == 1
MC/DC0%0/2
@kind == 1 and length $kind[0][1] == 1
@kind == 1
length $kind[0][1] == 1
Truth table33%1/3
A and B
A= @kind == 1B= length $kind[0][1] == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 6 | ▶ | return 0 unless @target == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | ▶ | return 0 if grep { $_->[0] == 0x03 && !_valid_tag_tuple($_->[1]) } @$entries; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_->[0] == 3 && !_valid_tag_tuple($_->[1])
MC/DC100%2/2
$_->[0] == 3 && !_valid_tag_tuple($_->[1])
$_->[0] == 3
!_valid_tag_tuple($_->[1])
Truth table100%3/3
A && not(B)
A= $_->[0] == 3B= !_valid_tag_tuple($_->[1])
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | my $kind = ord $kind[0][1]; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | ▶ | return length($target[0][1]) == 32 if $kind == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | ▶ | return defined _utf8($target[0][1]) if $kind == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 4 | ▶ | sub _valid_tag_tuple { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_tag_tuple: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 4 | my ($bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 4 | ▶ | return 0 unless length $bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | my $position = 0; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | my $key_length = ord substr($bytes, $position++, 1); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | ▶ | return 0 if $position + $key_length > length $bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 4 | ▶ | return 0 unless defined _utf8(substr($bytes, $position, $key_length)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 4 | $position += $key_length; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | my $values = 0; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 4 | ▶ | while ($position < length $bytes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | my $length = ord substr($bytes, $position++, 1); | |||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | return 0 if $position + $length > length $bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | ▶ | return 0 unless defined _utf8(substr($bytes, $position, $length)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | $position += $length; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | $values++; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 4 | return $values > 0; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 42 | ▶ | sub _tlv_entries { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tlv_entries: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 42 | my ($bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 42 | my @entries; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 42 | my $position = 0; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 42 | ▶ | while ($position < length $bytes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 146 | ▶ | return if length($bytes) - $position < 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 145 | my $type = ord substr($bytes, $position, 1); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 145 | my $length = unpack 'n', substr($bytes, $position + 1, 2); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 145 | $position += 3; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 145 | ▶ | return if $position + $length > length $bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 144 | push @entries, [$type, substr($bytes, $position, $length)]; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 144 | $position += $length; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 40 | return \@entries; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 14 | ▶ | sub _integer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_integer: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 14 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 14 | ▶ | return 0 if ref($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 14 | my $flags = B::svref_2object(\$value)->FLAGS; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 14 | ▶ | return ($flags & B::SVp_IOK()) && !($flags & (B::SVp_NOK() | B::SVp_POK())); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$flags & 4096 && !($flags & 24576)
MC/DC0%0/2
$flags & 4096 && !($flags & 24576)
$flags & 4096
!($flags & 24576)
Truth table33%1/3
A && not(B)
A= $flags & 4096B= !($flags & 24576)
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | sub _boolean { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_boolean: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | ▶ | return ref($value) && eval { $value->isa('Types::Serialiser::Boolean') } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $value and eval {
do {
$value->isa("Types::Serialiser::Boolean")
}
}
MC/DC50%1/2
ref $value and eval {
do {
$value->isa("Types::Serialiser::Boolean")
}
}
ref $value
eval {
do {
$value->isa("Types::Serialiser::Boolean")
}
}
Truth table66%2/3
A and B
A= ref $valueB= eval {
do {
$value->isa("Types::Serialiser::Boolean")
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 129 | ▶ | sub _text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_text: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 129 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 129 | ▶ | return defined $value && !ref($value) && utf8::is_utf8($value); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
defined $value && !ref($value) && utf8::is_utf8($value)
defined $value and not ref $value
MC/DC33%1/3
defined $value && !ref($value) && utf8::is_utf8($value)
defined $value
not ref $value
utf8::is_utf8($value)
Truth table50%2/4
A and not(B) && C
A= defined $valueB= not ref $valueC= utf8::is_utf8($value)
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 39 | ▶ | sub _utf8 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_utf8: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 39 | my ($bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 39 | my $text = eval { decode('UTF-8', $bytes, FB_CROAK) }; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 39 | ▶ | return if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 34 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 16 | ▶ | sub _decode_base64url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_base64url: called CC=6 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 16 | my ($encoded) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 16 | ▶ | return unless defined $encoded && !ref($encoded) && $encoded =~ /\A[A-Za-z0-9_-]+={0,2}\z/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $encoded and not ref $encoded and $encoded =~ /\A[A-Za-z0-9_-]+={0,2}\z/
defined $encoded and not ref $encoded
MC/DC0%0/3
defined $encoded and not ref $encoded and $encoded =~ /\A[A-Za-z0-9_-]+={0,2}\z/
defined $encoded
not ref $encoded
$encoded =~ /\A[A-Za-z0-9_-]+={0,2}\z/
Truth table25%1/4
A and not(B) and C
A= defined $encodedB= not ref $encodedC= $encoded =~ /\A[A-Za-z0-9_-]+={0,2}\z/
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 16 | $encoded =~ s/=+\z//; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 16 | ▶ | return if length($encoded) % 4 == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 16 | $encoded =~ tr{-_}{+/}; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 16 | ▶ | $encoded .= '=' while length($encoded) % 4; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 16 | return decode_base64($encoded); | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||