Skip to content

Fix TcfCaV1 (Canada) OptimizedRange encoding to use Fibonacci#106

Open
chuff wants to merge 1 commit into
IABTechLab:4.Xfrom
chuff:fix/canada-encoding-4x
Open

Fix TcfCaV1 (Canada) OptimizedRange encoding to use Fibonacci#106
chuff wants to merge 1 commit into
IABTechLab:4.Xfrom
chuff:fix/canada-encoding-4x

Conversation

@chuff

@chuff chuff commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Per the GPP Consent String Specification, the Canada (TcfCaV1) section encodes several fields as OptimizedRange / N-ArrayOfRanges, both of which use Fibonacci coding. They were using fixed-integer encoders. This ports the same fix to the 4.X architecture.

  • VendorExpressConsent, VendorImpliedConsent, DisclosedVendors (OptimizedRange) — EncodableOptimizedFixedRange → new EncodableOptimizedFibonacciRange, backed by a new OptimizedFibonacciRangeEncoder (mirrors OptimizedFixedRangeEncoder, swapping in the existing FibonacciIntegerRangeEncoder).
  • PubRestrictions (N-ArrayOfRanges(6,2), whose ids are an OptimizedRange) — EncodableArrayOfFixedIntegerRanges → new EncodableArrayOfOptimizedFibonacciRanges. The fixed variant is left untouched for TCF EU, which legitimately keeps the legacy encoding.

(Base64 is already correct on 4.X — TcfCaV1 uses the compressed Base64Segment for all segments.)

Output consistency

Byte-identical to the master-based fix (#105): the updated test vectors match exactly — e.g. the populated vendor section becomes …BhADVqxGAD0AILVgAA and PubRestrictions becomes …CCgAS7o. Empty / bitfield-form data is unchanged.

Scope

This is the encoding fix only. Backwards-compatible decoding of pre-fix (fixed-range) strings is a separate PR stacked on this branch (it will show only the decode changes once this merges).

Test plan

  • mvn test — 344 tests, 0 failures
  • mvn spotless:check — clean

🤖 Generated with Claude Code

Per the GPP Consent String Specification, the Canada section encodes
several fields as OptimizedRange / N-ArrayOfRanges, both of which use
Fibonacci coding. They were using fixed-integer encoders.

- VendorExpressConsent, VendorImpliedConsent, DisclosedVendors
  (OptimizedRange): EncodableOptimizedFixedRange ->
  EncodableOptimizedFibonacciRange (new), backed by a new
  OptimizedFibonacciRangeEncoder.
- PubRestrictions (N-ArrayOfRanges(6,2), whose ids are an OptimizedRange):
  EncodableArrayOfFixedIntegerRanges ->
  EncodableArrayOfOptimizedFibonacciRanges (new). The fixed variant is
  left untouched for TCF EU.

Output is byte-identical to the master-based fix (PR IABTechLab#105): updated test
vectors match (e.g. vendor section ...BhADVqxGAD0AILVgAA, PubRestrictions
...CCgAS7o).

This PR is the encoding fix only; backwards-compatible decoding of
pre-fix (fixed-range) strings follows in a separate PR stacked on this one.

mvn test: 344 tests, 0 failures; spotless:check clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant