You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Printing not possible with line break or mis-interpreted encoding in job title #1988
Install gv, a screen viewer for PostScript (or use "kghostview").
Create a PostScript file which does not contain a "%%Title:" line, either by printing from an appropriate application into a file (for example Firefox, document content does not matter) or by deleting this line from an existing PostScript file with a text editor.
Type
cat file.ps | /usr/lib/cups/filter/pstops 1 user a 1 "" > result.ps
gv result.ps
You will see your PostScript file in a window. Close the window.
Type
cat file.ps | /usr/lib/cups/filter/pstops 1 user 'a
and press . Then type
b' 1 "" > result.ps
and press again. You have made pstops now treating a job with the title "ab".
Do
gv result.ps
and you get an error.
So pstops cannot treat jobs whose titles have a newline inside, or where due to a misinterpreted encoding a byte of decimal value 13 (= ASCII value for newline) is not understood as part of a special character.
pstops should filter out the newlines and write all the text of the job title into one line.
I have used also a machine with CUPS 1.2.4 both as server and as client. for printing the example job of the Ubuntu report (see my test results there) and always could not print. Note that I printed from Firefox 1.5.x or 2.0beta (so encoding fixes in the command line clients have no effect, as these Firefox versions talk directly to the CUPS daemon). By printing to a file and then printing the file I could always print, as then no job title gets imposed to the job.
Reassigning the priority... FWIW, in all the years we've done printing software, we have never had a user submit a job with a title containing a newline...
Probably usually no one submits jobs with newlines intendedly, as I did to investigate this bug. It is more that applications take some string related to the document and add it to the print job as the job title. Sometimes such a string can contain a newline, but more probably is that the job title given by the application program is a non-ASCII encoding, ISO 8859-X, chinese, ... if the CUPS daemon (more and more apps are linked to the CUPS library and talk directly to the CUPS daemon) does not auto-detect this encoding, a byte of decimal value 13 (ASCII code of newline) can be interpreted as line break.
My suggestion is that, after the CUPS daemon has converted the job title to UTF-8 (or whatever encoding has to be used for the "%%Title:" line in the PostScript code) all non-printable characters (including newline) get stripped from the job title. If PostScript has a line length limit, the "%%Title:" line should be cut appropriately, too.
Activity
michaelrsweet commentedon Sep 26, 2006
CUPS.org User: mike
Reassigning the priority... FWIW, in all the years we've done printing software, we have never had a user submit a job with a title containing a newline...
michaelrsweet commentedon Sep 27, 2006
CUPS.org User: till.kamppeter
Probably usually no one submits jobs with newlines intendedly, as I did to investigate this bug. It is more that applications take some string related to the document and add it to the print job as the job title. Sometimes such a string can contain a newline, but more probably is that the job title given by the application program is a non-ASCII encoding, ISO 8859-X, chinese, ... if the CUPS daemon (more and more apps are linked to the CUPS library and talk directly to the CUPS daemon) does not auto-detect this encoding, a byte of decimal value 13 (ASCII code of newline) can be interpreted as line break.
My suggestion is that, after the CUPS daemon has converted the job title to UTF-8 (or whatever encoding has to be used for the "%%Title:" line in the PostScript code) all non-printable characters (including newline) get stripped from the job title. If PostScript has a line length limit, the "%%Title:" line should be cut appropriately, too.
michaelrsweet commentedon Oct 2, 2006
CUPS.org User: mike
Fixed in Subversion repository.
michaelrsweet commentedon Oct 2, 2006
"str1988.patch":
Index: imagetops.c
--- imagetops.c (revision 5996)
+++ imagetops.c (working copy)
@@ -609,8 +609,8 @@
puts("%%Creator: imagetops/" CUPS_SVERSION);
strftime(curdate, sizeof(curdate), "%c", curtm);
printf("%%%%CreationDate: %s\n", curdate);
if (Orientation & 1)
puts("%%Orientation: Landscape");
else
Index: texttops.c
===================================================================
--- texttops.c (revision 5996)
+++ texttops.c (working copy)
@@ -208,8 +208,8 @@
printf("%%cupsRotation: %d\n", (Orientation & 3) * 90);
puts("%%Creator: texttops/" CUPS_SVERSION);
printf("%%%%CreationDate: %s\n", curdate);
puts("%%Pages: (atend)");
/*
Index: common.c
--- common.c (revision 5996)
+++ common.c (working copy)
@@ -3,7 +3,7 @@
*
*
*
@@ -28,6 +28,7 @@
*/
-int Orientation = 0, /* 0 = portrait, 1 = landscape, etc. */
-float PageLeft = 18.0f, / Left margin */
+int Orientation = 0, / 0 = portrait, 1 = landscape, etc. */
+float PageLeft = 18.0f, / Left margin */
/*
*/
-ppd_file_t * /* O - PPD file /
-SetCommonOptions(int num_options, / I - Number of options */
+SetCommonOptions(
{
#ifdef LC_TIME
@@ -227,7 +229,7 @@
void
UpdatePageVars(void)
{
switch (Orientation & 3)
@@ -467,5 +469,76 @@
/*
+
+void
+WriteTextComment(const char *name, / I - Comment name ("Title", etc.) */
+}
+/*
End of "$Id$".
--- pstops.c (revision 5996)*/
Index: pstops.c
+++ pstops.c (working copy)
@@ -666,10 +666,10 @@
fputs("ERROR: No %%Pages: comment in header!\n", stderr);
if (!saw_for)
if (!saw_title)
if (doc->copies != 1 && (!doc->collate || !doc->slow_collate))
{
@@ -946,8 +946,8 @@
else
puts("%%Pages: 1");
if (doc->copies != 1 && (!doc->collate || !doc->slow_collate))
{
Index: hpgl-prolog.c
--- hpgl-prolog.c (revision 5996)
+++ hpgl-prolog.c (working copy)
@@ -70,8 +70,8 @@
puts("%%Creator: hpgltops/" CUPS_SVERSION);
strftime(line, sizeof(line), "%c", curtm);
printf("%%%%CreationDate: %s\n", line);
printf("%%cupsRotation: %d\n", (Orientation & 3) * 90);
puts("%%EndComments");
puts("%%BeginProlog");
Index: common.h
===================================================================
--- common.h (revision 5996)
+++ common.h (working copy)
@@ -3,7 +3,7 @@
Common filter definitions for the Common UNIX Printing System (CUPS).
*
* Copyright 1997-2005 by Easy Software Products.
@@ -76,6 +76,7 @@
extern void WriteLabelProlog(const char *label, float bottom,
float top, float width);
extern void WriteLabels(int orient);
+extern void WriteTextComment(const char *name, const char *value);
/*