From 0ef07096eaf248ac953ea7d5773dadb3a7f7c5d1 Mon Sep 17 00:00:00 2001 From: Alexander Popko Date: Thu, 27 Jun 2024 16:26:19 +0200 Subject: [PATCH 1/3] #607 Decode special characters as intended --- src/core/aztec/decoder/Decoder.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/aztec/decoder/Decoder.ts b/src/core/aztec/decoder/Decoder.ts index 7d891cae..7dcf3aaf 100644 --- a/src/core/aztec/decoder/Decoder.ts +++ b/src/core/aztec/decoder/Decoder.ts @@ -58,9 +58,9 @@ export default class Decoder { private static MIXED_TABLE: string[] = [ // Module parse failed: Octal literal in strict mode (50:29) // so number string were scaped - 'CTRL_PS', ' ', '\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '\\7', '\b', '\t', '\n', - '\\13', '\f', '\r', '\\33', '\\34', '\\35', '\\36', '\\37', '@', '\\', '^', '_', - '`', '|', '~', '\\177', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS' + 'CTRL_PS', ' ', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\b', '\t', '\n', + '\x0b', '\f', '\r', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', '@', '\\', '^', '_', + '`', '|', '~', '\x7f', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS' ]; private static PUNCT_TABLE: string[] = [ From 0ea914ab4945e1e4d528a4de16e4289b581350a5 Mon Sep 17 00:00:00 2001 From: Alexander Popko Date: Thu, 27 Jun 2024 16:28:07 +0200 Subject: [PATCH 2/3] #607 Remove outdated comment --- src/core/aztec/decoder/Decoder.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/aztec/decoder/Decoder.ts b/src/core/aztec/decoder/Decoder.ts index 7dcf3aaf..a8c229d3 100644 --- a/src/core/aztec/decoder/Decoder.ts +++ b/src/core/aztec/decoder/Decoder.ts @@ -56,8 +56,6 @@ export default class Decoder { ]; private static MIXED_TABLE: string[] = [ - // Module parse failed: Octal literal in strict mode (50:29) - // so number string were scaped 'CTRL_PS', ' ', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\b', '\t', '\n', '\x0b', '\f', '\r', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', '@', '\\', '^', '_', '`', '|', '~', '\x7f', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS' From 4ddfbccca951215249a0ddee79dcc0fdb8f0e21d Mon Sep 17 00:00:00 2001 From: Alexander Popko Date: Thu, 27 Jun 2024 17:06:05 +0200 Subject: [PATCH 3/3] #607 Test if special characters get correctly decoded --- src/test/core/aztec/decoder/Decoder.spec.ts | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/core/aztec/decoder/Decoder.spec.ts b/src/test/core/aztec/decoder/Decoder.spec.ts index 415d8ce7..fad128b4 100644 --- a/src/test/core/aztec/decoder/Decoder.spec.ts +++ b/src/test/core/aztec/decoder/Decoder.spec.ts @@ -155,6 +155,38 @@ describe('DecoderTest', () => { assertThrow(() => new AztecDecoder().decode(r), FormatException); }); + /** + * @Test + */ + it('testDecodeSpecialCharacters', () => { + const matrix = BitMatrix.parseFromString( + 'X X . . . X X . X X . X . . . . . . X \n' + + 'X . . X X . X . . X . . . X . X X X . \n' + + 'X . X . X X X X . . . X . . . . X . X \n' + + '. . . X X . X . . . . X . X X . X . X \n' + + 'X . X . X X . X . . X X . . X . . . . \n' + + '. . . X X X X X X X X X X X X X . X X \n' + + '. X X X . X . . . . . . . X . X X . X \n' + + 'X . X . X X . X X X X X . X X . . . . \n' + + '. X . X X X . X . . . X . X X . . X . \n' + + '. . . . . X . X . X . X . X . . . . X \n' + + '. . . X . X . X . . . X . X . . X X . \n' + + 'X . . . . X . X X X X X . X . X X X . \n' + + 'X . X . . X . . . . . . . X . X X . . \n' + + '. X X . . X X X X X X X X X X X . . . \n' + + 'X . X . . . X X X X X . . . . X . X X \n' + + '. . . X X X . . . X X X . X X . X X X \n' + + 'X X X . X X X X . X . X X . X X X X . \n' + + '. . . X . . X X . . X . X . X X . X X \n' + + 'X X . . X . X X X . . . . X . . . X X \n', + 'X ', '. '); + const r = new AztecDetectorResult(matrix, NO_POINTS, true, 14, 2); + const result = new AztecDecoder().decode(r); + assertEquals( + '\x01\x02\x03\x04\x05\x06\x07\x0b\x1b\x1c\x1d\x1e\x1f\x7f', + result.getText()); + }); + /** * @Test */