Long job names cause problems with some PJL printers #3125

Closed
michaelrsweet opened this Issue Mar 10, 2009 · 5 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Mar 10, 2009

Version: 1.3.9
CUPS.org User: franz.pfoertsch.brose

The PJL-Heade did not work all the time.

with both commands PJL JOB NAME and DISPLAY in one line, some machines get an line overflow and the commands will be ignored.

please fill in a new line and make this machines happy!

regards
Franz

Collaborator

michaelrsweet commented Mar 10, 2009

CUPS.org User: mike

You can't break off the DISPLAY part of the PJL JOB command. Better for us to truncate the title at a known limit.

Collaborator

michaelrsweet commented Mar 11, 2009

CUPS.org User: franz.pfoertsch.brose

You are right!

Here the header of a spooljob from samba:

---8<----
ESC%-12345X@PJL
@pjl JOB NAME = "smbprn.00000493 Microsoft Office Outlook - Memoformat" DISPLAY = "1767 pfoerfr smbprn.00000493 Microsoft Office Outlook - Memoformat"
@pjl RDYMSG DISPLAY = "1767 pfoerfr smbprn.00000493 Microsoft Office Outlook - Memoformat"
@pjl SET USERNAME = "pfoerfr"
@pjl SET KTRAPPING=0
@pjl SET HOLD=KUSERBOX
@pjl SET KUSERBOXID="0002"
@pjl SET KUSERBOXPASSWORD="1111"
@pjl ENTER LANGUAGE=POSTSCRIPT
---8<----

we should cut the "smbprn.00000493" stuff!
where does it come from?
who needs this?

I asked the samba volk and the told me it is from cups ?! ...

Collaborator

michaelrsweet commented Mar 11, 2009

CUPS.org User: mike

Fixed in Subversion repository.

The new code limits the display message to 32 characters + nul. In addition, CUPS 1.4's new cupsPJLDisplay PPD keyword can be used to display this entirely:

*cupsPJLDisplay: none
Collaborator

michaelrsweet commented Mar 11, 2009

"str3125-1.3.patch":

Index: cups/emit.c

--- cups/emit.c (revision 8423)
+++ cups/emit.c (working copy)
@@ -3,7 +3,7 @@
*

  • PPD code emission routines for the Common UNIX Printing System (CUPS).
  • * Copyright 2007-2008 by Apple Inc.
  • * Copyright 2007-2009 by Apple Inc.
  • Copyright 1997-2007 by Easy Software Products, all rights reserved.
  • These coded instructions, statements, and computer programs are the
    @@ -333,7 +333,8 @@
    const char title) / I - Title /
    {
    char *ptr; /
    Pointer into JCL string */
  • char temp[81]; /* Local title string */
  • char temp[65], /* Local title string */
  •   displaymsg[33];     /\* Local display string */
    

/*
@@ -400,14 +401,39 @@
}

/*

  • * Eliminate any path info from the job title...

    • Clean up the job title...
      */

    if ((ptr = strrchr(title, '/')) != NULL)

  • {

  • /*
    
  •  \* Only show basename of file path...
    
  •  */
    

    title = ptr + 1;

  • }

  • if (!strncmp(title, "smbprn.", 7))

  • {

  • /*
    
  •  \* Skip leading smbprn.######## from Samba jobs...
    
  •  */
    
  •  for (title += 7; _title && isdigit(_title & 255); title ++);
    
  •  for (; _title && isspace(_title & 255); title ++);
    
  •  if ((ptr = strstr(title, " - ")) != NULL)
    
  •  {
    
  •   /*
    
  • * Skip application name in "Some Application - Title of job"...

  • */

  • title = ptr + 3;
  •  }
    
  • }

/*

  • * Replace double quotes with single quotes and 8-bit characters with
  • * Replace double quotes with single quotes and UTF-8 characters with
  • question marks so that the title does not cause a PJL syntax error.
    */

@@ -416,16 +442,24 @@
for (ptr = temp; _ptr; ptr ++)
if (_ptr == '"')
*ptr = ''';

  •  else if (charset && (*ptr & 128))
    
  •  else if (!charset && (*ptr & 128))
     *ptr = '?';
    

    /*

  • * CUPS STR #3125: Long PJL JOB NAME causes problems with some printers

  • * Generate the display message, truncating at 32 characters + nul to avoid

  • * issues with some printer's PJL implementations...

  • */

  • snprintf(displaymsg, sizeof(displaymsg), "%d %s %s", job_id, user, temp);
  • /*
  • Send PJL JOB and PJL RDYMSG commands before we enter PostScript mode...
    */
  • fprintf(fp, "@pjl JOB NAME = "%s" DISPLAY = "%d %s %s"\n", temp,
  •        job_id, user, temp);
    
  • fprintf(fp, "@pjl RDYMSG DISPLAY = "%d %s %s"\n", job_id, user, temp);
  • fprintf(fp, "@pjl JOB NAME = "%s" DISPLAY = "%s"\n", temp, displaymsg);
  • fprintf(fp, "@pjl RDYMSG DISPLAY = "%s"\n", displaymsg);
    }
    else
    fputs(ppd->jcl_begin, fp);
Collaborator

michaelrsweet commented Mar 11, 2009

"str3125.patch":

Index: cups/emit.c

--- cups/emit.c (revision 8423)
+++ cups/emit.c (working copy)
@@ -3,7 +3,7 @@
*

  • PPD code emission routines for the Common UNIX Printing System (CUPS).
  • * Copyright 2007-2008 by Apple Inc.
  • * Copyright 2007-2009 by Apple Inc.
  • Copyright 1997-2007 by Easy Software Products, all rights reserved.
  • These coded instructions, statements, and computer programs are the
    @@ -390,7 +390,8 @@
    const char title) / I - Title /
    {
    char *ptr; /
    Pointer into JCL string */
  • char temp[81]; /* Local title string */
  • char temp[65], /* Local title string */
  •   displaymsg[33];     /\* Local display string */
    

/*
@@ -464,14 +465,39 @@
}

/*

  • * Eliminate any path info from the job title...

    • Clean up the job title...
      */

    if ((ptr = strrchr(title, '/')) != NULL)

  • {

  • /*
    
  •  \* Only show basename of file path...
    
  •  */
    

    title = ptr + 1;

  • }

  • if (!strncmp(title, "smbprn.", 7))

  • {

  • /*
    
  •  \* Skip leading smbprn.######## from Samba jobs...
    
  •  */
    
  •  for (title += 7; _title && isdigit(_title & 255); title ++);
    
  •  for (; _title && isspace(_title & 255); title ++);
    
  •  if ((ptr = strstr(title, " - ")) != NULL)
    
  •  {
    
  •   /*
    
  • * Skip application name in "Some Application - Title of job"...

  • */

  • title = ptr + 3;
  •  }
    
  • }

/*

  • * Replace double quotes with single quotes and 8-bit characters with
  • * Replace double quotes with single quotes and UTF-8 characters with
  • question marks so that the title does not cause a PJL syntax error.
    */

@@ -480,10 +506,19 @@
for (ptr = temp; _ptr; ptr ++)
if (_ptr == '"')
*ptr = ''';

  •  else if (charset && (*ptr & 128))
    
  •  else if (!charset && (*ptr & 128))
     *ptr = '?';
    

    /*

  • * CUPS STR #3125: Long PJL JOB NAME causes problems with some printers

  • * Generate the display message, truncating at 32 characters + nul to avoid

  • * issues with some printer's PJL implementations...

  • */

  • snprintf(displaymsg, sizeof(displaymsg), "%d %s %s", job_id, user, temp);
  • /*
  • Send PJL JOB and PJL RDYMSG commands before we enter PostScript mode...
    */

@@ -492,11 +527,11 @@
fprintf(fp, "@pjl JOB NAME = "%s"\n", temp);

   if (display && !strcmp(display->value, "rdymsg"))
  •    fprintf(fp, "@PJL RDYMSG DISPLAY = \"%d %s %s\"\n", job_id, user, temp);
    
  •    fprintf(fp, "@PJL RDYMSG DISPLAY = \"%s\"\n", displaymsg);
    
    }
    else
  •  fprintf(fp, "@PJL JOB NAME = \"%s\" DISPLAY = \"%d %s %s\"\n", temp,
    
  •     job_id, user, temp);
    
  •  fprintf(fp, "@PJL JOB NAME = \"%s\" DISPLAY = \"%s\"\n", temp,
    
  •     displaymsg);
    
    }
    else
    fputs(ppd->jcl_begin, fp);

michaelrsweet added this to the Stable milestone Mar 17, 2016

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