Fix TcfCaV1 (Canada) OptimizedRange encoding to use Fibonacci#106
Open
chuff wants to merge 1 commit into
Open
Conversation
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>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per the GPP Consent String Specification, the Canada (
TcfCaV1) section encodes several fields asOptimizedRange/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→ newEncodableOptimizedFibonacciRange, backed by a newOptimizedFibonacciRangeEncoder(mirrorsOptimizedFixedRangeEncoder, swapping in the existingFibonacciIntegerRangeEncoder).PubRestrictions(N-ArrayOfRanges(6,2), whoseidsare anOptimizedRange) —EncodableArrayOfFixedIntegerRanges→ newEncodableArrayOfOptimizedFibonacciRanges. The fixed variant is left untouched for TCF EU, which legitimately keeps the legacy encoding.(Base64 is already correct on 4.X —
TcfCaV1uses the compressedBase64Segmentfor 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
…BhADVqxGAD0AILVgAAandPubRestrictionsbecomes…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 failuresmvn spotless:check— clean🤖 Generated with Claude Code