Skip to content

Commit

Permalink
Merge pull request #608 from digital-h-gmbh/bugfix/607-wrong-characte…
Browse files Browse the repository at this point in the history
…rs-for-aztec-decoder-in-decoder-mixed-table
  • Loading branch information
werthdavid authored Jun 27, 2024
2 parents 39b2a01 + 4ddfbcc commit 2181128
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/core/aztec/decoder/Decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,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[] = [
Expand Down
32 changes: 32 additions & 0 deletions src/test/core/aztec/decoder/Decoder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 2181128

Please sign in to comment.