Skip to content

Commit 230c292

Browse files
chuffChad Huff
andauthored
usnat backwards compatibility for compressed padding (#82)
Co-authored-by: Chad Huff <chad@totalium.com>
1 parent 1051ddc commit 230c292

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsNatCoreSegment.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ protected void decodeSegment(String encodedString, EncodableBitStringFields fiel
9999
// Necessary to maintain backwards compatibility when sensitive data processing changed from a
100100
// length of 12 to 16 and known child sensitive data consents changed from a length of 2 to 3 in the
101101
// DE, IA, NE, NH, NJ, TN release
102-
if (bitString.length() == 66) {
102+
if (bitString.length() == 60) {
103+
bitString =
104+
bitString.substring(0, 48) + "00000000" + bitString.substring(48, 52) + "00" + bitString.substring(52, 60) + "00";
105+
}
106+
else if (bitString.length() == 66) {
103107
bitString =
104108
bitString.substring(0, 48) + "00000000" + bitString.substring(48, 52) + "00" + bitString.substring(52, 62);
105109
}

iabgpp-encoder/src/test/java/com/iab/gpp/encoder/section/UsNatTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,28 @@ public void testDecodeWithGpcSegmentExcluded() throws DecodingException {
228228
Assertions.assertEquals(2, usNat.getMspaServiceProviderMode());
229229
Assertions.assertEquals(false, usNat.getGpcSegmentIncluded());
230230
}
231+
232+
@Test
233+
public void testDecodeBackwardsCompatibility() throws DecodingException {
234+
UsNat usNat = new UsNat("BVQqAAAACg");
235+
236+
Assertions.assertEquals(1, usNat.getSharingNotice());
237+
Assertions.assertEquals(1, usNat.getSaleOptOutNotice());
238+
Assertions.assertEquals(1, usNat.getSharingOptOutNotice());
239+
Assertions.assertEquals(1, usNat.getTargetedAdvertisingOptOutNotice());
240+
Assertions.assertEquals(0, usNat.getSensitiveDataProcessingOptOutNotice());
241+
Assertions.assertEquals(0, usNat.getSensitiveDataLimitUseNotice());
242+
Assertions.assertEquals(2, usNat.getSaleOptOut());
243+
Assertions.assertEquals(2, usNat.getSharingOptOut());
244+
Assertions.assertEquals(2, usNat.getTargetedAdvertisingOptOut());
245+
Assertions.assertEquals(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), usNat.getSensitiveDataProcessing());
246+
Assertions.assertEquals(Arrays.asList(0, 0, 0), usNat.getKnownChildSensitiveDataConsents());
247+
Assertions.assertEquals(2, usNat.getPersonalDataConsents());
248+
Assertions.assertEquals(2, usNat.getMspaCoveredTransaction());
249+
Assertions.assertEquals(0, usNat.getMspaOptOutOptionMode());
250+
Assertions.assertEquals(0, usNat.getMspaServiceProviderMode());
251+
Assertions.assertEquals(false, usNat.getGpc());
252+
}
231253

232254
@Test()
233255
public void testDecodeGarbage() {

0 commit comments

Comments
 (0)