| 1 | package GDPR::IAB::TCFv2::Parser 0.530; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 73 | ▶ | use v5.12; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 73 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 73 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 73 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 73 | ▶ | use Carp qw<carp croak>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 73 | ▶ | use MIME::Base64 qw<decode_base64>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 73 | ▶ | use POSIX qw<strftime>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 73 | ▶ | use GDPR::IAB::TCFv2::BitField; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 73 | ▶ | use GDPR::IAB::TCFv2::BitUtils qw<is_set | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | get_uint3 | ||||||||||||||||||||||||||||||||||||||||||
| 15 | get_uint6 | ||||||||||||||||||||||||||||||||||||||||||
| 16 | get_uint12 | ||||||||||||||||||||||||||||||||||||||||||
| 17 | get_uint16 | ||||||||||||||||||||||||||||||||||||||||||
| 18 | get_uint36 | ||||||||||||||||||||||||||||||||||||||||||
| 19 | get_char6_pair | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 73 | >; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 73 | ▶ | use GDPR::IAB::TCFv2::Publisher; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 73 | ▶ | use GDPR::IAB::TCFv2::RangeSection; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 73 | ▶ | use GDPR::IAB::TCFv2::Constants::RestrictionType qw<:all>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 73 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 73 | CONSENT_STRING_TCF_V2 => {SEPARATOR => quotemeta q<.>, PREFIX => q<C>, MIN_BYTE_SIZE => 29,}, | |||||||||||||||||||||||||||||||||||||||||
| 27 | EXPECTED_TCF_V2_VERSION => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | MAX_SPECIAL_FEATURE_ID => 12, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | MAX_PURPOSE_ID => 24, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | DATE_FORMAT_ISO_8601 => '%Y-%m-%dT%H:%M:%SZ', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | TCF_V23_DEADLINE => 1772236800, # 2026-02-28T00:00:00Z | ||||||||||||||||||||||||||||||||||||||||||
| 32 | SEGMENT_TYPES => {CORE => 0, DISCLOSED_VENDORS => 1, ALLOWED_VENDORS => 2, PUBLISHER_TC => 3,}, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | OFFSETS => { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | SEGMENT_TYPE => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | VERSION => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | CREATED => 6, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | LAST_UPDATED => 42, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | CMP_ID => 78, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | CMP_VERSION => 90, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | CONSENT_SCREEN => 102, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | CONSENT_LANGUAGE => 108, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | VENDOR_LIST_VERSION => 120, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | POLICY_VERSION => 132, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | SERVICE_SPECIFIC => 138, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | USE_NON_STANDARD_STACKS => 139, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | SPECIAL_FEATURE_OPT_IN => 140, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | PURPOSE_CONSENT_ALLOWED => 152, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | PURPOSE_LIT_ALLOWED => 176, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | PURPOSE_ONE_TREATMENT => 200, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | PUBLISHER_COUNTRY_CODE => 201, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | VENDOR_CONSENT => 213, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 73 | }; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 73 | ▶ | use overload q<""> => \&tc_string; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | # ABSTRACT: gdpr iab tcf v2.3 consent string parser | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 11441 | ▶ | sub Parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Parse: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 11441 | my ($klass, $tc_string, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 11441 | ▶ | croak 'missing gdpr consent string' unless defined $tc_string && length $tc_string; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $tc_string and length $tc_string
MC/DC100%2/2
defined $tc_string and length $tc_string
defined $tc_string
length $tc_string
Truth table100%3/3
A and B
A= defined $tc_stringB= length $tc_string
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 11439 | my $segments = _decode_tc_string_segments($tc_string); | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 11428 | my $strict = !!$opts{strict}; | |||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 11428 | ▶ | my %options = (json => $opts{json} // {}, strict => $strict, reference_time => $opts{reference_time},); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"json"} // {}
MC/DC100%1/1
$opts{"json"} // {}
$opts{"json"}
Truth table100%2/2
A
A= $opts{"json"}
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 11428 | ▶ | $options{json}->{date_format} ||= DATE_FORMAT_ISO_8601; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options{"json"}{"date_format"} ||= "%Y-%m-%dT%H:%M:%SZ"
MC/DC100%1/1
$options{"json"}{"date_format"} ||= "%Y-%m-%dT%H:%M:%SZ"
$options{"json"}{"date_format"}
Truth table100%2/2
A
A= $options{"json"}{"date_format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 11428 | ▶ | $options{json}->{boolean_values} ||= [_json_false(), _json_true()]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options{"json"}{"boolean_values"} ||= [_json_false(), _json_true()]
MC/DC100%1/1
$options{"json"}{"boolean_values"} ||= [_json_false(), _json_true()]
$options{"json"}{"boolean_values"}
Truth table100%2/2
A
A= $options{"json"}{"boolean_values"}
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 11428 | ▶ | if (exists $opts{prefetch}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | my $prefetch = $opts{prefetch}; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | $prefetch = [$prefetch] if ref($prefetch) ne ref([]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | $options{prefetch} = $prefetch; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | core_data => $segments->{core_data}, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | disclosed_vendors_data => $segments->{disclosed_vendors}, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | allowed_vendors_data => $segments->{allowed_vendors}, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | publisher_tc_data => $segments->{publisher_tc}, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 11428 | options => \%options, | |||||||||||||||||||||||||||||||||||||||||
| 87 | tc_string => $tc_string, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | vendor_consents => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | vendor_legitimate_interests => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | publisher => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | disclosed_vendors => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | allowed_vendors => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 11428 | bless $self, $klass; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 11428 | ▶ | croak "consent string is not tcf version @{[ EXPECTED_TCF_V2_VERSION ]}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$strict and $self->version != 2
MC/DC100%2/2
$strict and $self->version != 2
$strict
$self->version != 2
Truth table100%3/3
A and B
A= $strictB= $self->version != 2
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | if $strict && $self->version != EXPECTED_TCF_V2_VERSION; | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 11426 | ▶ | croak 'invalid vendor list version' if $self->vendor_list_version == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | # TCF v2.3: Mandatory Disclosed Vendors segment check | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 11426 | ▶ | if ($strict && $self->is_v23) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$strict and $self->is_v23
MC/DC100%2/2
$strict and $self->is_v23
$strict
$self->is_v23
Truth table100%3/3
A and B
A= $strictB= $self->is_v23
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | ▶ | croak "TCF v2.3: Disclosed Vendors segment is mandatory" unless $self->has_vendor_disclosure; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 11421 | my $next_offset = $self->_parse_vendor_section(); | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 11418 | $self->_parse_publisher_section($next_offset); | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 11418 | $self->_parse_disclosed_vendors(); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 11417 | $self->_parse_allowed_vendors(); | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 11417 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 20533 | ▶ | sub tc_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tc_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 20533 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 20533 | return $self->{tc_string}; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 2110 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 2110 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2110 | return scalar(get_uint6($self->{core_data}, OFFSETS->{VERSION})); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 20180 | ▶ | sub created { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
created: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 20180 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 20180 | my ($seconds, $nanoseconds) = $self->_get_epoch(OFFSETS->{CREATED}); | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 20180 | ▶ | return wantarray ? ($seconds, $nanoseconds) : $seconds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 1071 | ▶ | sub last_updated { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_updated: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 1071 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 1071 | my ($seconds, $nanoseconds) = $self->_get_epoch(OFFSETS->{LAST_UPDATED}); | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 1071 | ▶ | return wantarray ? ($seconds, $nanoseconds) : $seconds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 21251 | ▶ | sub _get_epoch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_epoch: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 21251 | my ($self, $offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | # Drop the file-level `use integer` for this scope. TCF v2 stores | ||||||||||||||||||||||||||||||||||||||||||
| 150 | # Created and LastUpdated as a 36-bit deciseconds-since-epoch field, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | # which exceeds a 32-bit signed IV. On a Perl built without 64-bit | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # ints (e.g. the armv6l smokers), `get_uint36` returns the value as | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # an NV via Math::BigInt->numify; the C-integer `/` and `%` of | ||||||||||||||||||||||||||||||||||||||||||
| 154 | # `use integer` would then coerce that NV back into an overflowing | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # 32-bit IV. NV float math keeps full precision (36 bits fits in | ||||||||||||||||||||||||||||||||||||||||||
| 156 | # the 53-bit mantissa) and lands a correct integer result via int(). | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 73 | ▶ | no integer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 21251 | my $deciseconds = scalar(get_uint36($self->{core_data}, $offset)); | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 21251 | my $seconds = int($deciseconds / 10); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 21251 | my $nanoseconds = int(($deciseconds - $seconds * 10) * 100_000_000); | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 21251 | return ($seconds, $nanoseconds); | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 3128 | ▶ | sub cmp_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmp_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 3128 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 3128 | return scalar(get_uint12($self->{core_data}, OFFSETS->{CMP_ID})); | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 1067 | ▶ | sub cmp_version { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmp_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 1067 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 1067 | return scalar(get_uint12($self->{core_data}, OFFSETS->{CMP_VERSION})); | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 1066 | ▶ | sub consent_screen { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consent_screen: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 1066 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 1066 | return scalar(get_uint6($self->{core_data}, OFFSETS->{CONSENT_SCREEN})); | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1067 | ▶ | sub consent_language { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consent_language: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1067 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 1067 | return scalar(get_char6_pair($self->{core_data}, OFFSETS->{CONSENT_LANGUAGE})); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 12493 | ▶ | sub vendor_list_version { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vendor_list_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 12493 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 12493 | return scalar(get_uint12($self->{core_data}, OFFSETS->{VENDOR_LIST_VERSION})); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 31062 | ▶ | sub policy_version { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
policy_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 31062 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 31062 | return scalar(get_uint6($self->{core_data}, OFFSETS->{POLICY_VERSION})); | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 3813 | ▶ | sub is_v22_plus { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v22_plus: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 3813 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 3813 | ▶ | return $self->policy_version >= 4 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 14 | ▶ | sub is_v23 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v23: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 14 | my $deadline = TCF_V23_DEADLINE; | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | # If a reference_time was provided and it is BEFORE the deadline, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | # we skip all v2.3 checks to allow total historical simulation. | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 14 | ▶ | if (defined $self->{options}->{reference_time} && $self->{options}->{reference_time} < $deadline) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"options"}{"reference_time"} and $self->{"options"}{"reference_time"} < $deadline
MC/DC100%2/2
defined $self->{"options"}{"reference_time"} and $self->{"options"}{"reference_time"} < $deadline
defined $self->{"options"}{"reference_time"}
$self->{"options"}{"reference_time"} < $deadline
Truth table100%3/3
A and B
A= defined $self->{"options"}{"reference_time"}B= $self->{"options"}{"reference_time"} < $deadline
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 11 | ▶ | return 1 if $self->policy_version >= 5; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | # TCF v2.3 became mandatory on 2026-02-28. Strings created on or after | ||||||||||||||||||||||||||||||||||||||||||
| 221 | # this date are subject to v2.3 rules (e.g. mandatory Disclosed Vendors). | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 5 | ▶ | return 1 if $self->created >= $deadline; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 5 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 1066 | ▶ | sub is_service_specific { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_service_specific: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 1066 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 1066 | return scalar(is_set($self->{core_data}, OFFSETS->{SERVICE_SPECIFIC})); | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 1066 | ▶ | sub use_non_standard_stacks { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
use_non_standard_stacks: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 1066 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 1066 | return scalar(is_set($self->{core_data}, OFFSETS->{USE_NON_STANDARD_STACKS})); | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 27 | ▶ | sub is_special_feature_opt_in { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_special_feature_opt_in: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 27 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | croak "invalid special feature id $id: must be between 1 and @{[ MAX_SPECIAL_FEATURE_ID ]}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$id < 1 or $id > 12
MC/DC0%0/2
$id < 1 or $id > 12
$id < 1
$id > 12
Truth table33%1/3
A or B
A= $id < 1B= $id > 12
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | if $id < 1 || $id > MAX_SPECIAL_FEATURE_ID; | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 27 | return $self->_safe_is_special_feature_opt_in($id); | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 12795 | ▶ | sub _safe_is_special_feature_opt_in { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_safe_is_special_feature_opt_in: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 12795 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 12795 | return scalar(is_set($self->{core_data}, OFFSETS->{SPECIAL_FEATURE_OPT_IN} + $id - 1)); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 1077 | ▶ | sub is_purpose_consent_allowed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_purpose_consent_allowed: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 1077 | my ($self, @ids) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 1077 | $self->_validate_purpose_ids('is_purpose_consent_allowed', @ids); | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1076 | foreach my $id (@ids) { | |||||||||||||||||||||||||||||||||||||||||
| 260 | 1078 | ▶ | return 0 unless $self->_safe_is_purpose_consent_allowed($id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 1031 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 29832 | ▶ | sub _safe_is_purpose_consent_allowed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_safe_is_purpose_consent_allowed: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 29832 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 29832 | return scalar(is_set($self->{core_data}, OFFSETS->{PURPOSE_CONSENT_ALLOWED} + $id - 1)); | |||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 55 | ▶ | sub is_purpose_legitimate_interest_allowed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_purpose_legitimate_interest_allowed: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 55 | my ($self, @ids) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 55 | $self->_validate_purpose_ids('is_purpose_legitimate_interest_allowed', @ids); | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 54 | foreach my $id (@ids) { | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | # SPEC: Purpose 1 never allows Legitimate Interest | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 56 | ▶ | return 0 if $id == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | # SPEC: TCF v2.2+ (Policy >= 4) prohibits LI for Purposes 3, 4, 5, and 6 | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 52 | ▶ | if ($self->is_v22_plus) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | ▶ | return 0 if $id >= 3 && $id <= 6; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$id >= 3 and $id <= 6
MC/DC50%1/2
$id >= 3 and $id <= 6
$id >= 3
$id <= 6
Truth table66%2/3
A and B
A= $id >= 3B= $id <= 6
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 51 | ▶ | return 0 unless $self->_safe_is_purpose_legitimate_interest_allowed($id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 1132 | ▶ | sub _validate_purpose_ids { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_purpose_ids: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 1132 | my ($self, $method_name, @ids) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 1132 | ▶ | croak "method $method_name requires at least one argument" unless @ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 1130 | foreach my $id (@ids) { | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | croak "invalid purpose id $id: must be between 1 and @{[ MAX_PURPOSE_ID ]}" if $id < 1 || $id > MAX_PURPOSE_ID; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$id < 1 or $id > 24
MC/DC0%0/2
$id < 1 or $id > 24
$id < 1
$id > 24
Truth table33%1/3
A or B
A= $id < 1B= $id > 24
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 27138 | ▶ | sub _safe_is_purpose_legitimate_interest_allowed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_safe_is_purpose_legitimate_interest_allowed: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 27138 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 27138 | return scalar(is_set($self->{core_data}, OFFSETS->{PURPOSE_LIT_ALLOWED} + $id - 1)); | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 1067 | ▶ | sub purpose_one_treatment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
purpose_one_treatment: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 1067 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 1067 | return scalar(is_set($self->{core_data}, OFFSETS->{PURPOSE_ONE_TREATMENT})); | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 1066 | ▶ | sub publisher_country_code { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
publisher_country_code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 1066 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 1066 | return scalar(get_char6_pair($self->{core_data}, OFFSETS->{PUBLISHER_COUNTRY_CODE})); | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 3 | ▶ | sub max_vendor_id_consent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_vendor_id_consent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 3 | return $self->{vendor_consents}->max_id; | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 3 | ▶ | sub max_vendor_id_legitimate_interest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_vendor_id_legitimate_interest: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | return $self->{vendor_legitimate_interests}->max_id; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 15231 | ▶ | sub vendor_consent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vendor_consent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 15231 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 15231 | return $self->{vendor_consents}->contains($id); | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 4401 | ▶ | sub vendor_legitimate_interest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vendor_legitimate_interest: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 4401 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 4401 | return $self->{vendor_legitimate_interests}->contains($id); | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 110 | ▶ | sub disclosed_vendor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disclosed_vendor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 110 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 110 | ▶ | return 0 unless defined $self->{disclosed_vendors}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 110 | return $self->{disclosed_vendors}->contains($id); | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 9283 | ▶ | sub has_vendor_disclosure { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_vendor_disclosure: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 9283 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 9283 | ▶ | return defined $self->{disclosed_vendors} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | ▶ | sub allowed_vendor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allowed_vendor: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 1 | ▶ | return 0 unless defined $self->{allowed_vendors}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return $self->{allowed_vendors}->contains($id); | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 19319 | ▶ | sub check_publisher_restriction { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_publisher_restriction: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 19319 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 19319 | my ($purpose_id, $restriction_type, $vendor_id); | |||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 19319 | ▶ | if (scalar(@_) == 6) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 3 | my (%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 3 | $purpose_id = $opts{purpose_id}; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 3 | $restriction_type = $opts{restriction_type}; | |||||||||||||||||||||||||||||||||||||||||
| 375 | 3 | $vendor_id = $opts{vendor_id}; | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 19316 | ($purpose_id, $restriction_type, $vendor_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 19319 | return $self->{publisher}->check_restriction($purpose_id, $restriction_type, $vendor_id); | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 2 | ▶ | sub has_publisher_restrictions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_publisher_restrictions: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | ▶ | return $self->{publisher} ? $self->{publisher}->has_restrictions : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 8 | ▶ | sub publisher_restrictions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
publisher_restrictions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 8 | my ($self, $vendor_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 8 | return $self->{publisher}->restrictions($vendor_id); | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 4 | ▶ | sub publisher_tc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
publisher_tc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 4 | return $self->{publisher}->publisher_tc; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 3562 | ▶ | sub is_vendor_consent_allowed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_vendor_consent_allowed: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 3562 | my ($self, $vendor_id, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 3562 | my ($purpose_ids, $opts) = $self->_parse_vendor_args(@args); | |||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 3562 | foreach my $purpose_id (@$purpose_ids) { | |||||||||||||||||||||||||||||||||||||||||
| 407 | 3563 | ▶ | return 0 unless $self->_check_purpose_id($purpose_id, %$opts); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 3556 | ▶ | return 0 unless $self->vendor_consent($vendor_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 3409 | foreach my $purpose_id (@$purpose_ids) { | |||||||||||||||||||||||||||||||||||||||||
| 413 | 3410 | ▶ | return 0 if $self->check_publisher_restriction($purpose_id, NotAllowed, $vendor_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 3410 | ▶ | return 0 if $self->check_publisher_restriction($purpose_id, RequireLegitimateInterest, $vendor_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 3410 | ▶ | return 0 unless $self->_safe_is_purpose_consent_allowed($purpose_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 3321 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 1819 | ▶ | sub is_vendor_legitimate_interest_allowed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_vendor_legitimate_interest_allowed: called CC=12 SCAR=25.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 1819 | my ($self, $vendor_id, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 1819 | my ($purpose_ids, $opts) = $self->_parse_vendor_args(@args); | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 1819 | foreach my $purpose_id (@$purpose_ids) { | |||||||||||||||||||||||||||||||||||||||||
| 428 | 1819 | ▶ | return 0 unless $self->_check_purpose_id($purpose_id, %$opts); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 1819 | ▶ | return 0 unless $self->vendor_legitimate_interest($vendor_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 1757 | foreach my $purpose_id (@$purpose_ids) { | |||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | # SPEC: Purpose 1 never allows Legitimate Interest | ||||||||||||||||||||||||||||||||||||||||||
| 436 | 1757 | ▶ | return 0 if $purpose_id == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | # SPEC: TCF v2.2+ (Policy >= 4) prohibits LI for Purposes 3, 4, 5, and 6 | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 1742 | ▶ | if ($self->is_v22_plus) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 1413 | ▶ | return 0 if $purpose_id >= 3 && $purpose_id <= 6; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$purpose_id >= 3 and $purpose_id <= 6
MC/DC0%0/2
$purpose_id >= 3 and $purpose_id <= 6
$purpose_id >= 3
$purpose_id <= 6
Truth table66%2/3
A and B
A= $purpose_id >= 3B= $purpose_id <= 6
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 1742 | ▶ | return 0 if $self->check_publisher_restriction($purpose_id, NotAllowed, $vendor_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 1742 | ▶ | return 0 if $self->check_publisher_restriction($purpose_id, RequireConsent, $vendor_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 1742 | ▶ | return 0 unless $self->_safe_is_purpose_legitimate_interest_allowed($purpose_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 1598 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 5381 | ▶ | sub _parse_vendor_args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_vendor_args: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 5381 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 5381 | ▶ | if (@args && ref $args[-1] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@args and ref $args[-1] eq "HASH"
MC/DC0%0/2
@args and ref $args[-1] eq "HASH"
@args
ref $args[-1] eq "HASH"
Truth table33%1/3
A and B
A= @argsB= ref $args[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my $opts = pop @args; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | return (\@args, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 5381 | my @purposes; | |||||||||||||||||||||||||||||||||||||||||
| 461 | my %opts; | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 5381 | ▶ | while (@args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 9142 | ▶ | if ($args[0] =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 5382 | push @purposes, shift @args; | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 3760 | %opts = @args; | |||||||||||||||||||||||||||||||||||||||||
| 468 | 3760 | last; | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 5381 | return (\@purposes, \%opts); | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 195 | ▶ | sub is_vendor_allowed_for_any_basis { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_vendor_allowed_for_any_basis: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 195 | my ($self, $vendor_id, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 195 | ▶ | return 1 if $self->is_vendor_consent_allowed($vendor_id, @args); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 188 | ▶ | return 1 if $self->is_vendor_legitimate_interest_allowed($vendor_id, @args); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 100 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 2019 | ▶ | sub is_vendor_allowed_for_flexible_purpose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_vendor_allowed_for_flexible_purpose: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 2019 | my ($self, $vendor_id, $purpose_id, $default_is_li, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 2019 | ▶ | return 0 unless $self->_check_purpose_id($purpose_id, %opts); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | # SPEC: TCF v2.2+ (Policy >= 4) prohibits LI for Purposes 3, 4, 5, and 6 | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 2019 | ▶ | if ($self->is_v22_plus && $purpose_id >= 3 && $purpose_id <= 6) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->is_v22_plus and $purpose_id >= 3 and $purpose_id <= 6
$self->is_v22_plus and $purpose_id >= 3
MC/DC100%3/3
$self->is_v22_plus and $purpose_id >= 3 and $purpose_id <= 6
$self->is_v22_plus
$purpose_id >= 3
$purpose_id <= 6
Truth table100%4/4
A and B and C
A= $self->is_v22_plusB= $purpose_id >= 3C= $purpose_id <= 6
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | $default_is_li = 0; | |||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | # SPEC: Purpose 1 never allows Legitimate Interest | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 2019 | ▶ | if ($purpose_id == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $default_is_li = 0; | |||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 2019 | ▶ | if ($self->check_publisher_restriction($purpose_id, RequireConsent, $vendor_id)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 587 | return $self->is_vendor_consent_allowed($vendor_id, $purpose_id, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 1432 | ▶ | if ($self->check_publisher_restriction($purpose_id, RequireLegitimateInterest, $vendor_id)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 8 | return $self->is_vendor_legitimate_interest_allowed($vendor_id, $purpose_id, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 1424 | ▶ | if ($self->check_publisher_restriction($purpose_id, NotAllowed, $vendor_id)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 1422 | ▶ | if ($default_is_li) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 710 | return $self->is_vendor_legitimate_interest_allowed($vendor_id, $purpose_id, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 712 | return $self->is_vendor_consent_allowed($vendor_id, $purpose_id, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | 7401 | ▶ | sub _check_purpose_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_purpose_id: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 7401 | my ($self, $id, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 7401 | ▶ | my $strict = exists $opts{strict} ? $opts{strict} : $self->{options}->{strict}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 7401 | ▶ | if ($id < 1 || $id > MAX_PURPOSE_ID) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$id < 1 or $id > 24
MC/DC100%2/2
$id < 1 or $id > 24
$id < 1
$id > 24
Truth table100%3/3
A or B
A= $id < 1B= $id > 24
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 6 | ▶ | if ($strict) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 3 | croak "invalid purpose id $id: must be between 1 and @{[ MAX_PURPOSE_ID ]}"; | |||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 3 | carp "invalid purpose id $id: must be between 1 and @{[ MAX_PURPOSE_ID ]}"; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 7395 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 2128 | ▶ | sub _format_date { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_date: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 2128 | my ($self, $epoch, $nanoseconds) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 2128 | ▶ | return $epoch if !!$self->{options}->{json}->{use_epoch}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | 2124 | my $format = $self->{options}->{json}->{date_format}; | |||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 2124 | ▶ | return $format->($epoch, $nanoseconds) if ref($format) eq ref(sub { }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 2124 | return strftime($format, gmtime($epoch)); | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | sub _json_true { 1 == 1 } | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | sub _json_false { 1 == 0 } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 3192 | ▶ | sub _format_json_subsection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_json_subsection: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 3192 | my ($self, @data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 3192 | ▶ | if (!!$self->{options}->{json}->{compact}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 57 | return [map { $_->[0] } grep { $_->[1] } @data]; | |||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 3135 | my $verbose = !!$self->{options}->{json}->{verbose}; | |||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | 3135 | ▶ | return {map { @{$_} } grep { $verbose || $_->[1] } @data}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$verbose || $_->[1]
MC/DC100%2/2
$verbose || $_->[1]
$verbose
$_->[1]
Truth table100%3/3
A || B
A= $verboseB= $_->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||
| 564 | 1064 | ▶ | sub TO_JSON { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: called CC=14 SCAR=26.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 1064 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | my %args = (@_ && ref $_[-1] eq 'HASH') ? %{pop @_} : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and ref $_[-1] eq "HASH"
MC/DC0%0/2
@_ and ref $_[-1] eq "HASH"
@_
ref $_[-1] eq "HASH"
Truth table66%2/3
A and B
A= @_B= ref $_[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | 1064 | ▶ | my $filter_id = $args{vendor_id} // $self->{options}->{json}->{vendor_id}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$args{"vendor_id"} // $self->{"options"}{"json"}{"vendor_id"}
MC/DC100%2/2
$args{"vendor_id"} // $self->{"options"}{"json"}{"vendor_id"}
$args{"vendor_id"}
$self->{"options"}{"json"}{"vendor_id"}
Truth table100%3/3
A // B
A= $args{"vendor_id"}B= $self->{"options"}{"json"}{"vendor_id"}
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | 1064 | my ($false, $true) = @{$self->{options}->{json}->{boolean_values}}; | |||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 1064 | my $created = $self->_format_date($self->created); | |||||||||||||||||||||||||||||||||||||||||
| 573 | 1064 | my $last_updated = $self->_format_date($self->last_updated); | |||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | my $purpose_consents = $self->_format_json_subsection( | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 1064 | map { [ | |||||||||||||||||||||||||||||||||||||||||
| 577 | 25536 | ▶ | $_ => ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | $filter_id | ||||||||||||||||||||||||||||||||||||||||||
| 579 | ? $self->is_vendor_allowed_for_any_basis($filter_id, $_) | ||||||||||||||||||||||||||||||||||||||||||
| 580 | : $self->_safe_is_purpose_consent_allowed($_) | ||||||||||||||||||||||||||||||||||||||||||
| 581 | ) ? $true : $false | ||||||||||||||||||||||||||||||||||||||||||
| 582 | ] } 1 .. MAX_PURPOSE_ID, | ||||||||||||||||||||||||||||||||||||||||||
| 583 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | my $purpose_li = $self->_format_json_subsection( | ||||||||||||||||||||||||||||||||||||||||||
| 586 | 1064 | map { [ | |||||||||||||||||||||||||||||||||||||||||
| 587 | 25536 | ▶ | $_ => ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | $filter_id | ||||||||||||||||||||||||||||||||||||||||||
| 589 | ? $self->is_vendor_legitimate_interest_allowed($filter_id, $_) | ||||||||||||||||||||||||||||||||||||||||||
| 590 | : $self->_safe_is_purpose_legitimate_interest_allowed($_) | ||||||||||||||||||||||||||||||||||||||||||
| 591 | ) ? $true : $false | ||||||||||||||||||||||||||||||||||||||||||
| 592 | ] } 1 .. MAX_PURPOSE_ID, | ||||||||||||||||||||||||||||||||||||||||||
| 593 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 596 | tc_string => $self->tc_string, | ||||||||||||||||||||||||||||||||||||||||||
| 597 | version => $self->version, | ||||||||||||||||||||||||||||||||||||||||||
| 598 | created => $created, | ||||||||||||||||||||||||||||||||||||||||||
| 599 | last_updated => $last_updated, | ||||||||||||||||||||||||||||||||||||||||||
| 600 | cmp_id => $self->cmp_id, | ||||||||||||||||||||||||||||||||||||||||||
| 601 | cmp_version => $self->cmp_version, | ||||||||||||||||||||||||||||||||||||||||||
| 602 | consent_screen => $self->consent_screen, | ||||||||||||||||||||||||||||||||||||||||||
| 603 | consent_language => $self->consent_language, | ||||||||||||||||||||||||||||||||||||||||||
| 604 | vendor_list_version => $self->vendor_list_version, | ||||||||||||||||||||||||||||||||||||||||||
| 605 | policy_version => $self->policy_version, | ||||||||||||||||||||||||||||||||||||||||||
| 606 | is_service_specific => $self->is_service_specific ? $true : $false, | ||||||||||||||||||||||||||||||||||||||||||
| 607 | use_non_standard_stacks => $self->use_non_standard_stacks ? $true : $false, | ||||||||||||||||||||||||||||||||||||||||||
| 608 | purpose_one_treatment => $self->purpose_one_treatment ? $true : $false, | ||||||||||||||||||||||||||||||||||||||||||
| 609 | publisher_country_code => $self->publisher_country_code, | ||||||||||||||||||||||||||||||||||||||||||
| 610 | special_features_opt_in => $self->_format_json_subsection( | ||||||||||||||||||||||||||||||||||||||||||
| 611 | 12768 | ▶ | map { [$_ => $self->_safe_is_special_feature_opt_in($_) ? $true : $false] } 1 .. MAX_SPECIAL_FEATURE_ID | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 613 | purpose => {consents => $purpose_consents, legitimate_interests => $purpose_li,}, | ||||||||||||||||||||||||||||||||||||||||||
| 614 | vendor => { | ||||||||||||||||||||||||||||||||||||||||||
| 615 | consents => $self->{vendor_consents}->TO_JSON($filter_id), | ||||||||||||||||||||||||||||||||||||||||||
| 616 | legitimate_interests => $self->{vendor_legitimate_interests}->TO_JSON($filter_id), | ||||||||||||||||||||||||||||||||||||||||||
| 617 | ($self->{disclosed_vendors} ? (disclosed => $self->{disclosed_vendors}->TO_JSON($filter_id)) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 618 | ($self->{allowed_vendors} ? (allowed => $self->{allowed_vendors}->TO_JSON($filter_id)) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 619 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 620 | 1064 | ▶ | publisher => $self->{publisher}->TO_JSON($filter_id), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | 11439 | ▶ | sub _decode_tc_string_segments { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_tc_string_segments: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 625 | 11439 | my $tc_string = shift; | |||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 11439 | my ($core, @parts) = split CONSENT_STRING_TCF_V2->{SEPARATOR}, $tc_string; | |||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 11439 | my $core_data = _validate_and_decode_base64($core); | |||||||||||||||||||||||||||||||||||||||||
| 630 | 11432 | my $core_data_size = length($core_data); | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | croak | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 3 | "vendor consent strings are at least @{[ CONSENT_STRING_TCF_V2->{MIN_BYTE_SIZE} ]} bytes long (got ${core_data_size} bytes)" | |||||||||||||||||||||||||||||||||||||||||
| 634 | 11432 | ▶ | if $core_data_size < CONSENT_STRING_TCF_V2->{MIN_BYTE_SIZE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | 11429 | my %segments; | |||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 11429 | foreach my $part (@parts) { | |||||||||||||||||||||||||||||||||||||||||
| 639 | 10276 | my $decoded = _validate_and_decode_base64($part); | |||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | 10276 | my $segment_type = get_uint3($decoded, OFFSETS->{SEGMENT_TYPE}); | |||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | 10276 | ▶ | croak "duplicate segment type $segment_type" if exists $segments{$segment_type}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | 10275 | $segments{$segment_type} = $decoded; | |||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 649 | core_data => $core_data, | ||||||||||||||||||||||||||||||||||||||||||
| 650 | disclosed_vendors => $segments{SEGMENT_TYPES->{DISCLOSED_VENDORS}}, | ||||||||||||||||||||||||||||||||||||||||||
| 651 | allowed_vendors => $segments{SEGMENT_TYPES->{ALLOWED_VENDORS}}, | ||||||||||||||||||||||||||||||||||||||||||
| 652 | publisher_tc => $segments{SEGMENT_TYPES->{PUBLISHER_TC}}, | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 11428 | }; | |||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 21715 | ▶ | sub _validate_and_decode_base64 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_and_decode_base64: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | 21715 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | #Â see: https://www.perlmonks.org/?node_id=775820 | ||||||||||||||||||||||||||||||||||||||||||
| 660 | 21715 | ▶ | croak "invalid base64 format" unless $s =~ m{ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 661 | ^ | ||||||||||||||||||||||||||||||||||||||||||
| 662 | (?:[-A-Za-z0-9_]{4})* | ||||||||||||||||||||||||||||||||||||||||||
| 663 | (?: | ||||||||||||||||||||||||||||||||||||||||||
| 664 | [-A-Za-z0-9_]{2}[AEIMQUYcgkosw048] | ||||||||||||||||||||||||||||||||||||||||||
| 665 | | | ||||||||||||||||||||||||||||||||||||||||||
| 666 | [-A-Za-z0-9_][AQgw] | ||||||||||||||||||||||||||||||||||||||||||
| 667 | )? | ||||||||||||||||||||||||||||||||||||||||||
| 668 | \z | ||||||||||||||||||||||||||||||||||||||||||
| 669 | }x; | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 21708 | return _decode_base64url($s); | |||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | sub _decode_base64url { | ||||||||||||||||||||||||||||||||||||||||||
| 675 | my $s = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 676 | $s =~ tr/-_/+\//; | ||||||||||||||||||||||||||||||||||||||||||
| 677 | $s .= '=' while length($s) % 4; | ||||||||||||||||||||||||||||||||||||||||||
| 678 | return decode_base64($s); | ||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 11421 | ▶ | sub _parse_vendor_section { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_vendor_section: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | 11421 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | # parse vendor consent | ||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | 11421 | my $legitimate_interest_offset = $self->_parse_vendor_consents(OFFSETS->{VENDOR_CONSENT}); | |||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | #Â parse vendor legitimate interest | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 11421 | my $pub_restriction_offset = $self->_parse_vendor_legitimate_interests($legitimate_interest_offset); | |||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||
| 692 | 11418 | return $pub_restriction_offset; | |||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | 11421 | ▶ | sub _parse_vendor_consents { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_vendor_consents: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 696 | 11421 | my ($self, $vendor_consent_offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||
| 698 | 11421 | my ($vendor_consents, $legitimate_interest_offset) = $self->_parse_bitfield_or_range($vendor_consent_offset,); | |||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | 11421 | $self->{vendor_consents} = $vendor_consents; | |||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | 11421 | return $legitimate_interest_offset; | |||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||
| 705 | 11421 | ▶ | sub _parse_vendor_legitimate_interests { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_vendor_legitimate_interests: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | 11421 | my ($self, $legitimate_interest_offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | 11421 | my $data_size_bits = length($self->{core_data}) << 3; | |||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | my ($vendor_legitimate_interests, $pub_restriction_offset) = $self->_parse_bitfield_or_range( | ||||||||||||||||||||||||||||||||||||||||||
| 711 | $legitimate_interest_offset, | ||||||||||||||||||||||||||||||||||||||||||
| 712 | 11421 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 713 | 11421 | my $legitimate_interest_start = shift; | |||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | 11421 | ▶ | croak "invalid consent data: no legitimate interest start position" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | if $legitimate_interest_start >= $data_size_bits; | ||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 11421 | ); | |||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | 11418 | $self->{vendor_legitimate_interests} = $vendor_legitimate_interests; | |||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 11418 | return $pub_restriction_offset; | |||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | 11418 | ▶ | sub _parse_publisher_section { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_publisher_section: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | 11418 | my ($self, $pub_restriction_offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | # parse public restrictions | ||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | my $publisher = GDPR::IAB::TCFv2::Publisher->Parse( | ||||||||||||||||||||||||||||||||||||||||||
| 731 | core_data => $self->{core_data}, | ||||||||||||||||||||||||||||||||||||||||||
| 732 | core_data_size => length($self->{core_data}), | ||||||||||||||||||||||||||||||||||||||||||
| 733 | offset => $pub_restriction_offset, | ||||||||||||||||||||||||||||||||||||||||||
| 734 | publisher_tc_data => $self->{publisher_tc_data}, | ||||||||||||||||||||||||||||||||||||||||||
| 735 | options => $self->{options}, | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 11418 | ); | |||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | 11418 | $self->{publisher} = $publisher; | |||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | 11418 | ▶ | sub _parse_disclosed_vendors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_disclosed_vendors: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 742 | 11418 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | 11418 | ▶ | return unless defined $self->{disclosed_vendors_data}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | $self->{disclosed_vendors} | ||||||||||||||||||||||||||||||||||||||||||
| 747 | 592 | = $self->_parse_vendor_bitfield_or_range($self->{disclosed_vendors_data}, SEGMENT_TYPES->{DISCLOSED_VENDORS},); | |||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | 11417 | ▶ | sub _parse_allowed_vendors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_allowed_vendors: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 11417 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | 11417 | ▶ | return unless defined $self->{allowed_vendors_data}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | $self->{allowed_vendors} | ||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | = $self->_parse_vendor_bitfield_or_range($self->{allowed_vendors_data}, SEGMENT_TYPES->{ALLOWED_VENDORS},); | |||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | # Returns only $vendors_section -- unlike _parse_bitfield_or_range, which | ||||||||||||||||||||||||||||||||||||||||||
| 760 | # yields ($section, $next_offset) so the caller can keep parsing the core | ||||||||||||||||||||||||||||||||||||||||||
| 761 | # segment. Disclosed/Allowed Vendors live in their own base64 segment | ||||||||||||||||||||||||||||||||||||||||||
| 762 | # with nothing trailing the bitfield/range, so there is no offset to chain. | ||||||||||||||||||||||||||||||||||||||||||
| 763 | 594 | ▶ | sub _parse_vendor_bitfield_or_range { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_vendor_bitfield_or_range: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 764 | 594 | my ($self, $data, $expected_segment_type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | # If data looks like a string of 0/1 (from legacy tests), pack it. | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 594 | ▶ | if ($data =~ /^[01]+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 2 | $data = pack("B*", $data); | |||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | 594 | my ($segment_type, $offset) = get_uint3($data, 0); | |||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | 594 | ▶ | croak "invalid segment type $segment_type: expected $expected_segment_type" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $expected_segment_type and $segment_type != $expected_segment_type
MC/DC50%1/2
defined $expected_segment_type and $segment_type != $expected_segment_type
defined $expected_segment_type
$segment_type != $expected_segment_type
Truth table66%2/3
A and B
A= defined $expected_segment_typeB= $segment_type != $expected_segment_type
| |||||||||||||||||||||||||||||||||||||||||||
| 774 | if defined $expected_segment_type && $segment_type != $expected_segment_type; | ||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | 593 | my ($max_id, $next_offset) = get_uint16($data, $offset); | |||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | # Spec: MaxVendorId == 0 means "field unused". Skip the IsRange flag | ||||||||||||||||||||||||||||||||||||||||||
| 779 | # and any trailing payload entirely; return an empty BitField so that | ||||||||||||||||||||||||||||||||||||||||||
| 780 | # has_vendor_disclosure() still reports the segment as present while | ||||||||||||||||||||||||||||||||||||||||||
| 781 | # contains() always returns false for any vendor id. | ||||||||||||||||||||||||||||||||||||||||||
| 782 | 593 | ▶ | if ($max_id == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | my ($empty_section) = GDPR::IAB::TCFv2::BitField->Parse( | ||||||||||||||||||||||||||||||||||||||||||
| 784 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||
| 785 | data_size => length($data), | ||||||||||||||||||||||||||||||||||||||||||
| 786 | max_id => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 787 | offset => $next_offset, | ||||||||||||||||||||||||||||||||||||||||||
| 788 | options => $self->{options}, | ||||||||||||||||||||||||||||||||||||||||||
| 789 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 790 | 2 | return $empty_section; | |||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | 591 | my ($is_range, $bf_offset) = is_set($data, $next_offset); | |||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | 591 | my $vendors_section; | |||||||||||||||||||||||||||||||||||||||||
| 796 | 591 | ▶ | if ($is_range) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 797 | ($vendors_section,) = GDPR::IAB::TCFv2::RangeSection->Parse( | ||||||||||||||||||||||||||||||||||||||||||
| 798 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||
| 799 | data_size => length($data), | ||||||||||||||||||||||||||||||||||||||||||
| 800 | offset => $bf_offset, | ||||||||||||||||||||||||||||||||||||||||||
| 801 | max_id => $max_id, | ||||||||||||||||||||||||||||||||||||||||||
| 802 | options => $self->{options}, | ||||||||||||||||||||||||||||||||||||||||||
| 803 | 11 | ); | |||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||
| 805 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 806 | ($vendors_section,) = GDPR::IAB::TCFv2::BitField->Parse( | ||||||||||||||||||||||||||||||||||||||||||
| 807 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||
| 808 | data_size => length($data), | ||||||||||||||||||||||||||||||||||||||||||
| 809 | offset => $bf_offset, | ||||||||||||||||||||||||||||||||||||||||||
| 810 | max_id => $max_id, | ||||||||||||||||||||||||||||||||||||||||||
| 811 | options => $self->{options}, | ||||||||||||||||||||||||||||||||||||||||||
| 812 | 580 | ); | |||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | 590 | return $vendors_section; | |||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | 22842 | ▶ | sub _parse_bitfield_or_range { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_bitfield_or_range: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 819 | 22842 | my ($self, $offset, $validate_next_offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | 22842 | my $vendors_section; | |||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | 22842 | my ($max_id, $next_offset) = get_uint16($self->{core_data}, $offset); | |||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | 22842 | ▶ | $validate_next_offset->($next_offset) if defined $validate_next_offset; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | 22840 | my $is_range; | |||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | 22840 | ($is_range, $next_offset) = is_set($self->{core_data}, $next_offset,); | |||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | 22840 | ▶ | if ($is_range) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | 2470 | ($vendors_section, $next_offset) = $self->_parse_range_section($max_id, $next_offset,); | |||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||
| 834 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 20370 | ($vendors_section, $next_offset) = $self->_parse_bitfield($max_id, $next_offset,); | |||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | 22839 | ▶ | return wantarray ? ($vendors_section, $next_offset) : $vendors_section; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | 2470 | ▶ | sub _parse_range_section { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_range_section: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 842 | 2470 | my ($self, $max_id, $range_section_start_offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | my ($range_section, $next_offset) = GDPR::IAB::TCFv2::RangeSection->Parse( | ||||||||||||||||||||||||||||||||||||||||||
| 845 | data => $self->{core_data}, | ||||||||||||||||||||||||||||||||||||||||||
| 846 | data_size => length($self->{core_data}), | ||||||||||||||||||||||||||||||||||||||||||
| 847 | offset => $range_section_start_offset, | ||||||||||||||||||||||||||||||||||||||||||
| 848 | max_id => $max_id, | ||||||||||||||||||||||||||||||||||||||||||
| 849 | options => $self->{options}, | ||||||||||||||||||||||||||||||||||||||||||
| 850 | 2470 | ); | |||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 2470 | ▶ | return wantarray ? ($range_section, $next_offset) : $range_section; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | 20370 | ▶ | sub _parse_bitfield { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_bitfield: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | 20370 | my ($self, $max_id, $bitfield_start_offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | my ($bitfield, $next_offset) = GDPR::IAB::TCFv2::BitField->Parse( | ||||||||||||||||||||||||||||||||||||||||||
| 859 | data => $self->{core_data}, | ||||||||||||||||||||||||||||||||||||||||||
| 860 | data_size => length($self->{core_data}), | ||||||||||||||||||||||||||||||||||||||||||
| 861 | offset => $bitfield_start_offset, | ||||||||||||||||||||||||||||||||||||||||||
| 862 | max_id => $max_id, | ||||||||||||||||||||||||||||||||||||||||||
| 863 | options => $self->{options}, | ||||||||||||||||||||||||||||||||||||||||||
| 864 | 20370 | ); | |||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | 20369 | ▶ | return wantarray ? ($bitfield, $next_offset) : $bitfield; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||
| 869 | 73 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | 73 | ▶ | if (my $native_decode_base64url = MIME::Base64->can("decode_base64url")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 871 | 73 | ▶ | no warnings q<redefine>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||
| 873 | 73 | *_decode_base64url = $native_decode_base64url; | |||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||
| 876 | 73 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 877 | 73 | require JSON; | |||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | 73 | ▶ | if (my $native_json_true = JSON->can("true")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 880 | 73 | ▶ | no warnings q<redefine>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | 73 | *_json_true = $native_json_true; | |||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | 73 | ▶ | if (my $native_json_false = JSON->can("false")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 886 | 73 | ▶ | no warnings q<redefine>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | 73 | *_json_false = $native_json_false; | |||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||
| 890 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | 73 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 895 | __END__ | ||||||||||||||||||||||||||||||||||||||||||