Skip to content

Commit 529ef03

Browse files
committed
Tweak ZXing config to avoid QR Code fuzz failures
1 parent 43c996c commit 529ef03

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

src/test/java/uk/org/okapibarcode/backend/SymbolTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package uk.org.okapibarcode.backend;
1818

1919
import static java.lang.Integer.toHexString;
20+
import static java.nio.charset.StandardCharsets.ISO_8859_1;
2021
import static java.nio.charset.StandardCharsets.UTF_8;
2122
import static org.junit.jupiter.api.Assertions.assertEquals;
2223
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -657,9 +658,10 @@ public static BufferedImage draw(Symbol symbol) {
657658
public static Result decode(BufferedImage image, Reader reader) throws ReaderException {
658659
LuminanceSource source = new BufferedImageLuminanceSource(image);
659660
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
660-
Map< DecodeHintType, Boolean > hints = new HashMap<>();
661+
Map< DecodeHintType, Object > hints = new HashMap<>();
661662
hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
662663
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
664+
hints.put(DecodeHintType.CHARACTER_SET, ISO_8859_1.name()); // help QR Code reader
663665
return reader.decode(bitmap, hints);
664666
}
665667

Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
PROPERTIES
2+
3+
content=[rcdeg\u00b2b241\u0001]0
4+
5+
LOG
6+
7+
ECI Mode: 3
8+
ECI Charset: ISO-8859-1
9+
Encoding: BYTE 91 114 99 100 101 103 178 98 NUMB 241 BYTE 1 93 48
10+
Codewords: 64 133 183 38 54 70 86 123 38 33 0 207 20 3 1 93 48 0 236
11+
Version: 1
12+
ECC Level: L
13+
Mask 000 Penalties: 103 241 801 801
14+
Mask 001 Penalties: 137 377 897 EXIT
15+
Mask 010 Penalties: 132 312 832 EXIT
16+
Mask 011 Penalties: 124 307 787 797
17+
Mask 100 Penalties: 134 371 851 EXIT
18+
Mask 101 Penalties: 130 361 841 EXIT
19+
Mask 110 Penalties: 130 358 878 EXIT
20+
Mask 111 Penalties: 145 346 826 EXIT
21+
Mask Pattern: 011
22+
Blocks Merged: 118 -> 82
23+
24+
CODEWORDS
25+
26+
7122117
27+
151412151
28+
113111113111311
29+
113111221111311
30+
1131113311311
31+
151421151
32+
711111117
33+
092:
34+
4211112112311
35+
0111131322213
36+
02213223114
37+
0112211513121
38+
5111111121141
39+
081311412
40+
73121322
41+
1512121332
42+
11311211122122
43+
1131111113121111
44+
113111113512
45+
15111411141
46+
71153112

0 commit comments

Comments
 (0)