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

Locations containing a number sign (#) doesn't load on startup #2254

Closed
michaelrsweet opened this issue Feb 21, 2007 · 2 comments
Closed

Locations containing a number sign (#) doesn't load on startup #2254

michaelrsweet opened this issue Feb 21, 2007 · 2 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.2-current
CUPS.org User: krumboeck

Hi!

We set this locations with lpadmin. Sadly this only works as long you don't restart CUPS. All location strings will be truncted by the number sign.

lpadmin should reject or correctly encode this character.

Maybe other fields are also affected, but we don't tried it.

best regards!
Bernd

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"str2254.patch":

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, "<Printer %s>\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, "<Class %s>\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");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant