@@ -4975,12 +4975,14 @@ _ppdCreateFromIPP2(
49754975
49764976 cupsArrayAdd (templates , (void * )keyword );
49774977
4978+ pwg_ppdize_name (keyword , ppdname , sizeof (ppdname ));
4979+
49784980 snprintf (msgid , sizeof (msgid ), "finishing-template.%s" , keyword );
49794981 if ((msgstr = _cupsLangString (lang , msgid )) == msgid || !strcmp (msgid , msgstr ))
49804982 if ((msgstr = _cupsMessageLookup (strings , msgid )) == msgid )
49814983 msgstr = keyword ;
49824984
4983- cupsFilePrintf (fp , "*cupsFinishingTemplate %s: \"\n" , keyword );
4985+ cupsFilePrintf (fp , "*cupsFinishingTemplate %s: \"\n" , ppdname );
49844986 for (finishing_attr = ippFirstAttribute (finishing_col ); finishing_attr ; finishing_attr = ippNextAttribute (finishing_col ))
49854987 {
49864988 if (ippGetValueTag (finishing_attr ) == IPP_TAG_BEGIN_COLLECTION )
@@ -4993,7 +4995,7 @@ _ppdCreateFromIPP2(
49934995 }
49944996 }
49954997 cupsFilePuts (fp , "\"\n" );
4996- cupsFilePrintf (fp , "*%s.cupsFinishingTemplate %s/%s: \"\"\n" , lang -> language , keyword , msgstr );
4998+ cupsFilePrintf (fp , "*%s.cupsFinishingTemplate %s/%s: \"\"\n" , lang -> language , ppdname , msgstr );
49974999 cupsFilePuts (fp , "*End\n" );
49985000 }
49995001
@@ -5039,7 +5041,8 @@ _ppdCreateFromIPP2(
50395041 if (!preset || !preset_name )
50405042 continue ;
50415043
5042- cupsFilePrintf (fp , "*APPrinterPreset %s: \"\n" , preset_name );
5044+ pwg_ppdize_name (preset_name , ppdname , sizeof (ppdname ));
5045+ cupsFilePrintf (fp , "*APPrinterPreset %s: \"\n" , ppdname );
50435046 for (member = ippFirstAttribute (preset ); member ; member = ippNextAttribute (preset ))
50445047 {
50455048 member_name = ippGetName (member );
@@ -5080,7 +5083,10 @@ _ppdCreateFromIPP2(
50805083 fin_col = ippGetCollection (member , i );
50815084
50825085 if ((keyword = ippGetString (ippFindAttribute (fin_col , "finishing-template" , IPP_TAG_ZERO ), 0 , NULL )) != NULL )
5083- cupsFilePrintf (fp , "*cupsFinishingTemplate %s\n" , keyword );
5086+ {
5087+ pwg_ppdize_name (keyword , ppdname , sizeof (ppdname ));
5088+ cupsFilePrintf (fp , "*cupsFinishingTemplate %s\n" , ppdname );
5089+ }
50845090 }
50855091 }
50865092 else if (!strcmp (member_name , "media" ))
@@ -5107,13 +5113,13 @@ _ppdCreateFromIPP2(
51075113 if ((keyword = ippGetString (ippFindAttribute (media_col , "media-source" , IPP_TAG_ZERO ), 0 , NULL )) != NULL )
51085114 {
51095115 pwg_ppdize_name (keyword , ppdname , sizeof (ppdname ));
5110- cupsFilePrintf (fp , "*InputSlot %s\n" , keyword );
5116+ cupsFilePrintf (fp , "*InputSlot %s\n" , ppdname );
51115117 }
51125118
51135119 if ((keyword = ippGetString (ippFindAttribute (media_col , "media-type" , IPP_TAG_ZERO ), 0 , NULL )) != NULL )
51145120 {
51155121 pwg_ppdize_name (keyword , ppdname , sizeof (ppdname ));
5116- cupsFilePrintf (fp , "*MediaType %s\n" , keyword );
5122+ cupsFilePrintf (fp , "*MediaType %s\n" , ppdname );
51175123 }
51185124 }
51195125 else if (!strcmp (member_name , "print-quality" ))
@@ -5159,7 +5165,10 @@ _ppdCreateFromIPP2(
51595165 cupsFilePuts (fp , "\"\n*End\n" );
51605166
51615167 if ((localized_name = _cupsMessageLookup (strings , preset_name )) != preset_name )
5162- cupsFilePrintf (fp , "*%s.APPrinterPreset %s/%s: \"\"\n" , lang -> language , preset_name , localized_name );
5168+ {
5169+ pwg_ppdize_name (preset_name , ppdname , sizeof (ppdname ));
5170+ cupsFilePrintf (fp , "*%s.APPrinterPreset %s/%s: \"\"\n" , lang -> language , ppdname , localized_name );
5171+ }
51635172 }
51645173 }
51655174
@@ -5543,7 +5552,7 @@ pwg_ppdize_name(const char *ipp, /* I - IPP keyword */
55435552 * end ; /* End of name buffer */
55445553
55455554
5546- if (!ipp )
5555+ if (!ipp || ! _cups_isalnum ( * ipp ) )
55475556 {
55485557 * name = '\0' ;
55495558 return ;
@@ -5558,8 +5567,14 @@ pwg_ppdize_name(const char *ipp, /* I - IPP keyword */
55585567 ipp ++ ;
55595568 * ptr ++ = (char )toupper (* ipp ++ & 255 );
55605569 }
5561- else
5570+ else if (* ipp == '_' || * ipp == '.' || * ipp == '-' || _cups_isalnum (* ipp ))
5571+ {
55625572 * ptr ++ = * ipp ++ ;
5573+ }
5574+ else
5575+ {
5576+ ipp ++ ;
5577+ }
55635578 }
55645579
55655580 * ptr = '\0' ;
0 commit comments