Enhanced data length checks for GS1 data

Brought up to date with revision 19 of the GS1 General Specifications
This commit is contained in:
Roman Schnider 2019-03-18 17:24:07 +01:00
parent a083b300e4
commit dcf0cbef97

View File

@ -198,7 +198,7 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s
strcpy(ai_string, "");
// Check for valid AI values and data lengths according to GS1 General
// Specification Release 18, January 2018
// Specification Release 19, January 2019
for (i = 0; i < ai_count; i++) {
error_latch = 2;
@ -435,6 +435,15 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s
}
break;
// Length 50 Max
case 8009: // OPTSEN
if (data_length[i] > 50) {
error_latch = 1;
} else {
error_latch = 0;
}
break;
// Length 70 Max
case 8110: // Coupon code
case 8112: // Paperless coupon code
@ -569,6 +578,14 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s
}
}
if ((ai_value[i] >= 7230) && (ai_value[i] <= 7239)) { // CERT #
if ((data_length[i] < 3) || (data_length[i] > 30)) {
error_latch = 1;
} else {
error_latch = 0;
}
}
if (ai_value[i] == 8003) { // GRAI
if ((data_length[i] < 15) || (data_length[i] > 30)) {
error_latch = 1;