Description: Some printers have broken device IDs with newline characters inside. These break the cups-deviced printer discovery mechanism and so the printers get ignored. This patch allows newline characters in device IDs Bug-Ubuntu: https://bugs.launchpad.net/bugs/468701 Author: Till Kamppeter --- a/scheduler/cups-deviced.c +++ b/scheduler/cups-deviced.c @@ -577,15 +577,30 @@ if (*ptr == '\"') { - for (ptr ++, device_id = ptr; *ptr && *ptr != '\"'; ptr ++) + for (ptr ++, device_id = ptr; *ptr != '\"'; ptr ++) { if (*ptr == '\\' && ptr[1]) _cups_strcpy(ptr, ptr + 1); + if (!*ptr) + { + fprintf(stderr, "WARNING: [cups-deviced] Possible newline in device ID \"%s\": %s\n", + backend->name, line); + *ptr = ' '; + ptr ++; + *ptr = 0; + if (!cupsFileGets(backend->pipe, ptr, sizeof(line) - (ptr - temp))) + { + cupsFileClose(backend->pipe); + backend->pipe = NULL; + fprintf(stderr, "ERROR: [cups-deviced] Bad line from \"%s\": %s\n", + backend->name, line); + return (-1); + } + } + if (!*ptr) + goto error; } - if (*ptr != '\"') - goto error; - for (*ptr++ = '\0'; isspace(*ptr & 255); *ptr++ = '\0'); /*