Expand ECI support and enforce binary mode when ECI is set

This commit is contained in:
Robin Stuart
2017-07-23 17:59:51 +01:00
parent d818d1aecc
commit 451f0150d8
6 changed files with 52 additions and 10 deletions

View File

@ -1212,6 +1212,11 @@ int dotcode(struct zint_symbol *symbol, const unsigned char source[], int length
unsigned char* masked_codeword_array;
unsigned char* codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char));
#endif /* _MSC_VER */
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "Invalid ECI");
return ZINT_ERROR_INVALID_OPTION;
}
data_length = dotcode_encode_message(symbol, source, length, codeword_array, &binary_finish);

View File

@ -1053,6 +1053,11 @@ int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], size_t
}
if (symbol->output_options & READER_INIT) reader = 1;
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "Invalid ECI");
return ZINT_ERROR_INVALID_OPTION;
}
error_number = gm_encode(gbdata, length, binary, reader, symbol->eci, symbol->debug);
if (error_number != 0) {

View File

@ -485,7 +485,6 @@ static int supports_eci(const int symbology) {
case BARCODE_DOTCODE:
case BARCODE_GRIDMATRIX:
case BARCODE_HANXIN:
case BARCODE_UPNQR:
result = 1;
break;
}
@ -991,6 +990,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source,int
if ((symbol->input_mode < 0) || (symbol->input_mode > 2)) {
symbol->input_mode = DATA_MODE;
}
if (symbol->eci != 3) {
symbol->input_mode = DATA_MODE;
}
if (symbol->input_mode == GS1_MODE) {
for (i = 0; i < in_length; i++) {

View File

@ -559,12 +559,10 @@ void numbprocess(int *chainemc, int *mclength, char chaine[], int start, int len
/* 366 */
static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_t length) {
int i, k, j, indexchaine, indexliste, mode, longueur, loop, mccorrection[520], offset;
int total, chainemc[2700], mclength, c1, c2, c3, dummy[35], codeerr;
int total, chainemc[2700], mclength, c1, c2, c3, dummy[35];
char pattern[580];
int debug = symbol->debug;
codeerr = 0;
/* 456 */
indexliste = 0;
indexchaine = 0;
@ -639,6 +637,11 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size
}
}
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "Invalid ECI");
return ZINT_ERROR_INVALID_OPTION;
}
for (i = 0; i < indexliste; i++) {
switch (liste[1][i]) {
case TEX: /* 547 - text mode */
@ -821,7 +824,7 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size
symbol->width =(int)strlen(pattern);
/* 843 */
return codeerr;
return 0;
}
/* 345 */
@ -863,6 +866,9 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[], const size_t l
strcpy(symbol->errtxt, "Data too long for specified number of columns (D65)");
error_number = ZINT_ERROR_TOO_LONG;
break;
case ZINT_ERROR_INVALID_OPTION:
error_number = codeerr;
break;
default:
strcpy(symbol->errtxt, "Something strange happened (D66)");
error_number = ZINT_ERROR_ENCODING_PROBLEM;
@ -936,6 +942,11 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_
mclength++;
}
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "Invalid ECI");
return ZINT_ERROR_INVALID_OPTION;
}
if (symbol->eci != 3) {
/* Encoding ECI assignment number, according to Table 8 */
if (symbol->eci <= 899) {