Skip to content

Commit 236a336

Browse files
Merge pull request #1 from digital-h-gmbh/bugfix/607-wrong-characters-for-aztec-decoder-in-decoder-mixed-table
Wrong characters for Aztec decoder in `Decoder.MIXED_TABLE`
2 parents 39b2a01 + 4ddfbcc commit 236a336

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

src/core/aztec/decoder/Decoder.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ export default class Decoder {
5656
];
5757

5858
private static MIXED_TABLE: string[] = [
59-
// Module parse failed: Octal literal in strict mode (50:29)
60-
// so number string were scaped
61-
'CTRL_PS', ' ', '\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '\\7', '\b', '\t', '\n',
62-
'\\13', '\f', '\r', '\\33', '\\34', '\\35', '\\36', '\\37', '@', '\\', '^', '_',
63-
'`', '|', '~', '\\177', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS'
59+
'CTRL_PS', ' ', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\b', '\t', '\n',
60+
'\x0b', '\f', '\r', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', '@', '\\', '^', '_',
61+
'`', '|', '~', '\x7f', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS'
6462
];
6563

6664
private static PUNCT_TABLE: string[] = [

src/test/core/aztec/decoder/Decoder.spec.ts

+32
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,38 @@ describe('DecoderTest', () => {
155155
assertThrow(() => new AztecDecoder().decode(r), FormatException);
156156
});
157157

158+
/**
159+
* @Test
160+
*/
161+
it('testDecodeSpecialCharacters', () => {
162+
const matrix = BitMatrix.parseFromString(
163+
'X X . . . X X . X X . X . . . . . . X \n' +
164+
'X . . X X . X . . X . . . X . X X X . \n' +
165+
'X . X . X X X X . . . X . . . . X . X \n' +
166+
'. . . X X . X . . . . X . X X . X . X \n' +
167+
'X . X . X X . X . . X X . . X . . . . \n' +
168+
'. . . X X X X X X X X X X X X X . X X \n' +
169+
'. X X X . X . . . . . . . X . X X . X \n' +
170+
'X . X . X X . X X X X X . X X . . . . \n' +
171+
'. X . X X X . X . . . X . X X . . X . \n' +
172+
'. . . . . X . X . X . X . X . . . . X \n' +
173+
'. . . X . X . X . . . X . X . . X X . \n' +
174+
'X . . . . X . X X X X X . X . X X X . \n' +
175+
'X . X . . X . . . . . . . X . X X . . \n' +
176+
'. X X . . X X X X X X X X X X X . . . \n' +
177+
'X . X . . . X X X X X . . . . X . X X \n' +
178+
'. . . X X X . . . X X X . X X . X X X \n' +
179+
'X X X . X X X X . X . X X . X X X X . \n' +
180+
'. . . X . . X X . . X . X . X X . X X \n' +
181+
'X X . . X . X X X . . . . X . . . X X \n',
182+
'X ', '. ');
183+
const r = new AztecDetectorResult(matrix, NO_POINTS, true, 14, 2);
184+
const result = new AztecDecoder().decode(r);
185+
assertEquals(
186+
'\x01\x02\x03\x04\x05\x06\x07\x0b\x1b\x1c\x1d\x1e\x1f\x7f',
187+
result.getText());
188+
});
189+
158190
/**
159191
* @Test
160192
*/

0 commit comments

Comments
 (0)