From: Michael R Sweet Date: Mon, 9 Sep 2024 19:52:52 +0000 (-0400) Subject: PPDize preset and template names. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a4803788244ba1a7bc5359212c00d7f8eb665f3;p=thirdparty%2Fcups.git PPDize preset and template names. --- diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index ae87ce3dc5..8fed03a4d6 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -4899,9 +4899,11 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ cupsArrayAdd(templates, (void *)keyword); + pwg_ppdize_name(keyword, ppdname, sizeof(ppdname)); + snprintf(msgid, sizeof(msgid), "finishing-template.%s", keyword); - cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\n", keyword, ppd_get_string(base_lang, lang, msgid, ppdtext, sizeof(ppdtext))); + cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\n", ppdname, ppd_get_string(base_lang, lang, msgid, ppdtext, sizeof(ppdtext))); for (finishing_attr = ippFirstAttribute(finishing_col); finishing_attr; finishing_attr = ippNextAttribute(finishing_col)) { if (ippGetValueTag(finishing_attr) == IPP_TAG_BEGIN_COLLECTION) @@ -4959,7 +4961,9 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ if (!preset || !preset_name) continue; - cupsFilePrintf(fp, "*APPrinterPreset %s: \"\n", preset_name); + pwg_ppdize_name(preset_name, ppdname, sizeof(ppdname)); + + cupsFilePrintf(fp, "*APPrinterPreset %s: \"\n", ppdname); for (member = ippFirstAttribute(preset); member; member = ippNextAttribute(preset)) { member_name = ippGetName(member); @@ -5000,7 +5004,10 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ fin_col = ippGetCollection(member, i); if ((keyword = ippGetString(ippFindAttribute(fin_col, "finishing-template", IPP_TAG_ZERO), 0, NULL)) != NULL) - cupsFilePrintf(fp, "*cupsFinishingTemplate %s\n", keyword); + { + pwg_ppdize_name(keyword, ppdname, sizeof(ppdname)); + cupsFilePrintf(fp, "*cupsFinishingTemplate %s\n", ppdname); + } } } else if (!strcmp(member_name, "media")) @@ -5027,13 +5034,13 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ if ((keyword = ippGetString(ippFindAttribute(media_col, "media-source", IPP_TAG_ZERO), 0, NULL)) != NULL) { pwg_ppdize_name(keyword, ppdname, sizeof(ppdname)); - cupsFilePrintf(fp, "*InputSlot %s\n", keyword); + cupsFilePrintf(fp, "*InputSlot %s\n", ppdname); } if ((keyword = ippGetString(ippFindAttribute(media_col, "media-type", IPP_TAG_ZERO), 0, NULL)) != NULL) { pwg_ppdize_name(keyword, ppdname, sizeof(ppdname)); - cupsFilePrintf(fp, "*MediaType %s\n", keyword); + cupsFilePrintf(fp, "*MediaType %s\n", ppdname); } } else if (!strcmp(member_name, "print-quality")) @@ -5706,7 +5713,7 @@ pwg_ppdize_name(const char *ipp, /* I - IPP keyword */ *end; /* End of name buffer */ - if (!ipp) + if (!ipp || !_cups_isalnum(*ipp)) { *name = '\0'; return; @@ -5721,8 +5728,14 @@ pwg_ppdize_name(const char *ipp, /* I - IPP keyword */ ipp ++; *ptr++ = (char)toupper(*ipp++ & 255); } - else + else if (*ipp == '_' || *ipp == '.' || *ipp == '-' || _cups_isalnum(*ipp)) + { *ptr++ = *ipp++; + } + else + { + ipp ++; + } } *ptr = '\0';