Index: cups/file.c =================================================================== --- cups/file.c (revision 6310) +++ cups/file.c (working copy) @@ -508,7 +508,7 @@ */ *value = NULL; - + while (cupsFileGets(fp, buf, buflen)) { (*linenum) ++; @@ -519,15 +519,24 @@ if ((ptr = strchr(buf, '#')) != NULL) { - while (ptr > buf) + if (ptr > buf && ptr[-1] == '\\') { - if (!isspace(ptr[-1] & 255)) - break; + // Unquote the #... + _cups_strcpy(ptr - 1, ptr); + } + else + { + // Strip the comment and any trailing whitespace... + while (ptr > buf) + { + if (!isspace(ptr[-1] & 255)) + break; - ptr --; + ptr --; + } + + *ptr = '\0'; } - - *ptr = '\0'; } /* Index: scheduler/printers.c =================================================================== --- scheduler/printers.c (revision 6310) +++ scheduler/printers.c (working copy) @@ -1289,6 +1289,7 @@ time_t curtime; /* Current time */ struct tm *curdate; /* Current date */ cups_option_t *option; /* Current option */ + const char *ptr; /* Pointer into info/location */ /* @@ -1363,11 +1364,40 @@ cupsFilePrintf(fp, "\n", printer->name); if (printer->info) - cupsFilePrintf(fp, "Info %s\n", printer->info); + { + if ((ptr = strchr(printer->info, '#')) != NULL) + { + /* + * Need to quote the first # in the info string... + */ + cupsFilePuts(fp, "Info "); + cupsFileWrite(fp, printer->info, ptr - printer->info); + cupsFilePutChar(fp, '\\'); + cupsFilePuts(fp, ptr); + cupsFilePutChar(fp, '\n'); + } + else + cupsFilePrintf(fp, "Info %s\n", printer->info); + } + if (printer->location) - cupsFilePrintf(fp, "Location %s\n", printer->location); + { + if ((ptr = strchr(printer->info, '#')) != NULL) + { + /* + * Need to quote the first # in the location string... + */ + cupsFilePuts(fp, "Location "); + cupsFileWrite(fp, printer->location, ptr - printer->location); + cupsFilePutChar(fp, '\\'); + cupsFilePuts(fp, ptr); + cupsFilePutChar(fp, '\n'); + } + else + cupsFilePrintf(fp, "Location %s\n", printer->location); + } if (printer->device_uri) cupsFilePrintf(fp, "DeviceURI %s\n", printer->device_uri); Index: scheduler/classes.c =================================================================== --- scheduler/classes.c (revision 6310) +++ scheduler/classes.c (working copy) @@ -3,7 +3,7 @@ * * Printer class routines for the Common UNIX Printing System (CUPS). * - * Copyright 1997-2006 by Easy Software Products, all rights reserved. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -703,6 +703,7 @@ time_t curtime; /* Current time */ struct tm *curdate; /* Current date */ cups_option_t *option; /* Current option */ + const char *ptr; /* Pointer into info/location */ /* @@ -777,11 +778,41 @@ cupsFilePrintf(fp, "\n", pclass->name); if (pclass->info) - cupsFilePrintf(fp, "Info %s\n", pclass->info); + { + if ((ptr = strchr(pclass->info, '#')) != NULL) + { + /* + * Need to quote the first # in the info string... + */ + cupsFilePuts(fp, "Info "); + cupsFileWrite(fp, pclass->info, ptr - pclass->info); + cupsFilePutChar(fp, '\\'); + cupsFilePuts(fp, ptr); + cupsFilePutChar(fp, '\n'); + } + else + cupsFilePrintf(fp, "Info %s\n", pclass->info); + } + if (pclass->location) - cupsFilePrintf(fp, "Location %s\n", pclass->location); + { + if ((ptr = strchr(pclass->info, '#')) != NULL) + { + /* + * Need to quote the first # in the location string... + */ + cupsFilePuts(fp, "Location "); + cupsFileWrite(fp, pclass->location, ptr - pclass->location); + cupsFilePutChar(fp, '\\'); + cupsFilePuts(fp, ptr); + cupsFilePutChar(fp, '\n'); + } + else + cupsFilePrintf(fp, "Location %s\n", pclass->location); + } + if (pclass->state == IPP_PRINTER_STOPPED) { cupsFilePuts(fp, "State Stopped\n");