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);