Index: backend/snmp-supplies.c =================================================================== --- backend/snmp-supplies.c (revision 10242) +++ backend/snmp-supplies.c (working copy) @@ -408,7 +408,7 @@ cachefilename[1024], /* Cache filename */ description[CUPS_SNMP_MAX_STRING], /* Device description string */ - value[CUPS_MAX_SUPPLIES * (CUPS_SNMP_MAX_STRING * 2 + 3)], + value[CUPS_MAX_SUPPLIES * (CUPS_SNMP_MAX_STRING * 4 + 3)], /* Value string */ *ptr, /* Pointer into value string */ *name_ptr; /* Pointer into name string */ @@ -659,7 +659,8 @@ fprintf(stderr, "ATTR: marker-colors=%s\n", value); /* - * Output the marker-names attribute... + * Output the marker-names attribute (the double quoting is necessary to deal + * with embedded quotes and commas in the marker names...) */ for (i = 0, ptr = value; i < num_supplies; i ++) @@ -667,15 +668,21 @@ if (i) *ptr++ = ','; + *ptr++ = '\''; *ptr++ = '\"'; for (name_ptr = supplies[i].name; *name_ptr;) { - if (*name_ptr == '\\' || *name_ptr == '\"') + if (*name_ptr == '\\' || *name_ptr == '\"' || *name_ptr == '\'') + { *ptr++ = '\\'; + *ptr++ = '\\'; + *ptr++ = '\\'; + } *ptr++ = *name_ptr++; } *ptr++ = '\"'; + *ptr++ = '\''; } *ptr = '\0'; @@ -834,7 +841,6 @@ { char *src, *dst; /* Pointers into strings */ - /* * Loop safe because both the object_value and supplies char arrays * are CUPS_SNMP_MAX_STRING elements long. Index: backend/ipp.c =================================================================== --- backend/ipp.c (revision 10251) +++ backend/ipp.c (working copy) @@ -2561,17 +2561,23 @@ case IPP_TAG_TEXT : case IPP_TAG_NAME : case IPP_TAG_KEYWORD : + *valptr++ = '\''; *valptr++ = '\"'; for (attrptr = attr->values[i].string.text; *attrptr && valptr < (value + sizeof(value) - 10); attrptr ++) { - if (*attrptr == '\\' || *attrptr == '\"') + if (*attrptr == '\\' || *attrptr == '\"' || *attrptr == '\'') + { *valptr++ = '\\'; + *valptr++ = '\\'; + *valptr++ = '\\'; + } *valptr++ = *attrptr; } *valptr++ = '\"'; + *valptr++ = '\''; break; default : Index: scheduler/printers.c =================================================================== --- scheduler/printers.c (revision 10242) +++ scheduler/printers.c (working copy) @@ -3,7 +3,7 @@ * * Printer routines for the CUPS scheduler. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -1915,7 +1915,9 @@ ipp_attribute_t *attr; /* Attribute */ int i, /* Looping var */ count; /* Number of values */ - char *ptr; /* Pointer into value */ + char *ptr, /* Pointer into value */ + *start, /* Start of value */ + quote; /* Quote character */ ipp_tag_t value_tag; /* Value tag for this attribute */ @@ -1933,9 +1935,21 @@ * Count the number of values... */ - for (count = 1, ptr = value; - (ptr = strchr(ptr, ',')) != NULL; - ptr ++, count ++); + for (count = 1, quote = '\0', ptr = value; + *ptr; + ptr ++) + { + if (*ptr == quote) + quote = '\0'; + else if (quote) + continue; + else if (*ptr == '\\' && ptr[1]) + ptr ++; + else if (*ptr == '\'' || *ptr == '\"') + quote = *ptr; + else if (*ptr == '.') + count ++; + } /* * Then add or update the attribute as needed... @@ -2019,15 +2033,33 @@ return; } - for (i = 0; i < count; i ++) + for (i = 0, quote = '\0', ptr = value; i < count; i ++) { - if ((ptr = strchr(value, ',')) != NULL) - *ptr++ = '\0'; + for (start = ptr; *ptr; ptr ++) + { + if (*ptr == quote) + *ptr = quote = '\0'; + else if (quote) + continue; + else if (*ptr == '\\' && ptr[1]) + _cups_strcpy(ptr, ptr + 1); + else if (*ptr == '\'' || *ptr == '\"') + { + quote = *ptr; - attr->values[i].string.text = _cupsStrAlloc(value); + if (ptr == start) + start ++; + else + _cups_strcpy(ptr, ptr + 1); + } + else if (*ptr == '.') + { + *ptr++ = '\0'; + break; + } + } - if (ptr) - value = ptr; + attr->values[i].string.text = _cupsStrAlloc(start); } } }