Detect invalid input to Code 39 encoder and reject it more explicitly

git-svn-id: https://zxing.googlecode.com/svn/trunk@2803 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-05-19 15:56:15 +00:00
parent 619ff4b882
commit 6fe6504dad

View file

@ -54,6 +54,9 @@ public final class Code39Writer extends OneDimensionalCodeWriter {
int codeWidth = 24 + 1 + length;
for (int i = 0; i < length; i++) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
if (indexInString < 0) {
throw new IllegalArgumentException("Bad contents: " + contents);
}
toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
for (int width : widths) {
codeWidth += width;