Skip to content

Commit

Permalink
rename property
Browse files Browse the repository at this point in the history
  • Loading branch information
peczenyj committed Dec 11, 2023
1 parent 15c2182 commit 4480a3d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
16 changes: 8 additions & 8 deletions lib/GDPR/IAB/TCFv2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -542,25 +542,25 @@ sub _is_vendor_consent_range_encoding {
}

sub _parse_range_section {
my ( $self, $vendor_bits_required, $start_bit ) = @_;
my ( $self, $max_vendor_id, $start_bit ) = @_;

my ( $range_section, $next_offset ) =
GDPR::IAB::TCFv2::RangeSection->Parse(
data => $self->{data},
start_bit => $start_bit,
vendor_bits_required => $vendor_bits_required,
data => $self->{data},
start_bit => $start_bit,
max_vendor_id => $max_vendor_id,
);

return ( $range_section, $next_offset );
}

sub _parse_bitfield {
my ( $self, $vendor_bits_required, $start_bit ) = @_;
my ( $self, $max_vendor_id, $start_bit ) = @_;

my ( $bitfield, $next_offset ) = GDPR::IAB::TCFv2::BitField->Parse(
data => $self->{data},
start_bit => $start_bit,
vendor_bits_required => $vendor_bits_required,
data => $self->{data},
start_bit => $start_bit,
max_vendor_id => $max_vendor_id,
);

return ( $bitfield, $next_offset );
Expand Down
30 changes: 15 additions & 15 deletions lib/GDPR/IAB/TCFv2/BitField.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ sub Parse {

croak "missing 'data'" unless defined $args{data};
croak "missing 'start_bit'" unless defined $args{start_bit};
croak "missing 'vendor_bits_required'"
unless defined $args{vendor_bits_required};
croak "missing 'max_vendor_id'"
unless defined $args{max_vendor_id};

my $data = $args{data};
my $start_bit = $args{start_bit};
my $vendor_bits_required = $args{vendor_bits_required};
my $data = $args{data};
my $start_bit = $args{start_bit};
my $max_vendor_id = $args{max_vendor_id};

my $data_size = length($data);

# add 7 to force rounding to next integer value
my $bytes_required = ( $vendor_bits_required + $start_bit + 7 ) / 8;
my $bytes_required = ( $max_vendor_id + $start_bit + 7 ) / 8;

croak
"a BitField for $vendor_bits_required requires a consent string of $bytes_required bytes. This consent string had $data_size"
"a BitField for $max_vendor_id requires a consent string of $bytes_required bytes. This consent string had $data_size"
if $data_size < $bytes_required;

my $self = {
data => substr( $data, $start_bit ),
vendor_bits_required => $vendor_bits_required,
data => substr( $data, $start_bit ),
max_vendor_id => $max_vendor_id,
};

bless $self, $klass;

return ( $self, $start_bit + $vendor_bits_required );
return ( $self, $start_bit + $max_vendor_id );
}

sub max_vendor_id {
my $self = shift;

return $self->{vendor_bits_required};
return $self->{max_vendor_id};
}

sub contains {
Expand All @@ -50,7 +50,7 @@ sub contains {
croak "invalid vendor id $id: must be positive integer bigger than 0"
if $id < 1;

return if $id > $self->{vendor_bits_required};
return if $id > $self->{max_vendor_id};

return is_set( $self->{data}, $id - 1 );
}
Expand All @@ -69,9 +69,9 @@ GDPR::IAB::TCFv2::BitField - Transparency & Consent String version 2 bitfield pa
my $max_vendor_id_consent = << get 16 bits from $data offset 213 >>
my $bit_field = GDPR::IAB::TCFv2::BitField->Parse(
data => $data,
start_bit => 230, # offset for vendor consents
vendor_bits_required => $max_vendor_id_consent
data => $data,
start_bit => 230, # offset for vendor consents
max_vendor_id => $max_vendor_id_consent,
);
if $bit_field->contains(284) { ... }
Expand Down
26 changes: 13 additions & 13 deletions lib/GDPR/IAB/TCFv2/RangeSection.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ sub Parse {

croak "missing 'data'" unless defined $args{data};
croak "missing 'start_bit'" unless defined $args{start_bit};
croak "missing 'vendor_bits_required'"
unless defined $args{vendor_bits_required};
croak "missing 'max_vendor_id'"
unless defined $args{max_vendor_id};

my $data = $args{data};
my $start_bit = $args{start_bit};
my $vendor_bits_required = $args{vendor_bits_required};
my $data = $args{data};
my $start_bit = $args{start_bit};
my $max_vendor_id = $args{max_vendor_id};


my $data_size = length($data);
Expand All @@ -35,15 +35,15 @@ sub Parse {
my $consent;
( $consent, $next_offset ) = _parse_range_consent(
$data, $next_offset,
$vendor_bits_required
$max_vendor_id
);

push @consents, $consent;
}

my $self = {
consents => \@consents,
vendor_bits_required => $vendor_bits_required,
consents => \@consents,
max_vendor_id => $max_vendor_id,
};

bless $self, $klass;
Expand Down Expand Up @@ -97,7 +97,7 @@ sub _parse_range_consent {
sub max_vendor_id {
my $self = shift;

return $self->{vendor_bits_required};
return $self->{max_vendor_id};
}

sub contains {
Expand All @@ -106,7 +106,7 @@ sub contains {
croak "invalid vendor id $id: must be positive integer bigger than 0"
if $id < 1;

return if $id > $self->{vendor_bits_required};
return if $id > $self->{max_vendor_id};

foreach my $c ( @{ $self->{consents} } ) {
return 1 if $c->contains($id);
Expand All @@ -129,9 +129,9 @@ GDPR::IAB::TCFv2::RangeSection - Transparency & Consent String version 2 range s
my $max_vendor_id_consent = << get 16 bits from $data offset 213 >>
my ($range_section, $next_offset) = GDPR::IAB::TCFv2::RangeSection->Parse(
data => $data,
start_bit => 230, # offset for vendor consents
vendor_bits_required => $max_vendor_id_consent
data => $data,
start_bit => 230, # offset for vendor consents
max_vendor_id => $max_vendor_id_consent,
);
if $range_section->contains(284) { ... }
Expand Down

0 comments on commit 4480a3d

Please sign in to comment.