Summary
When a 14-digit ITF-14 code is provided (with check digit), src/encoders/itf.ts does not validate that the check digit is correct. It just passes the raw 14 digits through.
Details
export function encodeITF14(text: string): number[] {
validateDigitsOnly(text);
let digits: string;
if (text.length === 13) {
const nums = text.split("").map(Number);
const check = calculateCheckDigit(nums);
digits = text + String(check);
} else if (text.length === 14) {
digits = text; // No validation!
} else {
throw new InvalidInputError("ITF-14 requires 13 or 14 digits");
}
return encodeITF(digits);
}
When 14 digits are provided, the check digit (last digit) should be verified against the calculated value, similar to how UPC-A does it.
Impact
ITF-14 barcodes with incorrect check digits are silently accepted. These barcodes will fail GS1 verification.
Summary
When a 14-digit ITF-14 code is provided (with check digit),
src/encoders/itf.tsdoes not validate that the check digit is correct. It just passes the raw 14 digits through.Details
When 14 digits are provided, the check digit (last digit) should be verified against the calculated value, similar to how UPC-A does it.
Impact
ITF-14 barcodes with incorrect check digits are silently accepted. These barcodes will fail GS1 verification.