Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debian: Fix conversion of PPD InputSlot choice names #23

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions cups/ppd-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -5145,6 +5145,8 @@ pwg_unppdize_name(const char *ppd, /* I - PPD keyword */
{
char *ptr, /* Pointer into name buffer */
*end; /* End of name buffer */
int nodash = 1; /* Next char in IPP name cannot be a
dash (first char or after a dash) */


if (_cups_islower(*ppd))
Expand All @@ -5156,7 +5158,9 @@ pwg_unppdize_name(const char *ppd, /* I - PPD keyword */
const char *ppdptr; /* Pointer into PPD keyword */

for (ppdptr = ppd + 1; *ppdptr; ppdptr ++)
if (_cups_isupper(*ppdptr) || strchr(dashchars, *ppdptr))
if (_cups_isupper(*ppdptr) || strchr(dashchars, *ppdptr) ||
(*ppdptr == '-' && *(ppdptr - 1) == '-') ||
(*ppdptr == '-' && *(ppdptr + 1) == '\0'))
break;

if (!*ppdptr)
Expand All @@ -5168,19 +5172,44 @@ pwg_unppdize_name(const char *ppd, /* I - PPD keyword */

for (ptr = name, end = name + namesize - 1; *ppd && ptr < end; ppd ++)
{
if (_cups_isalnum(*ppd) || *ppd == '-')
if (_cups_isalnum(*ppd))
{
*ptr++ = (char)tolower(*ppd & 255);
else if (strchr(dashchars, *ppd))
*ptr++ = '-';
nodash = 0;
}
else if (*ppd == '-' || strchr(dashchars, *ppd))
{
if (nodash == 0)
{
*ptr++ = '-';
nodash = 1;
}
}
else
{
*ptr++ = *ppd;
nodash = 0;
}

if (!_cups_isupper(*ppd) && _cups_isalnum(*ppd) &&
_cups_isupper(ppd[1]) && ptr < end)
*ptr++ = '-';
else if (!isdigit(*ppd & 255) && isdigit(ppd[1] & 255))
*ptr++ = '-';
if (nodash == 0)
{
if (!_cups_isupper(*ppd) && _cups_isalnum(*ppd) &&
_cups_isupper(ppd[1]) && ptr < end)
{
*ptr++ = '-';
nodash = 1;
}
else if (!isdigit(*ppd & 255) && isdigit(ppd[1] & 255))
{
*ptr++ = '-';
nodash = 1;
}
}
}

/* Remove trailing dashes */
while (ptr > name && *(ptr - 1) == '-')
ptr --;

*ptr = '\0';
}