]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: In pdftops() identify old LaserJets more precisely
authorTill Kamppeter <till.kamppeter@gmail.com>
Tue, 5 Apr 2022 15:38:43 +0000 (17:38 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Tue, 5 Apr 2022 15:38:43 +0000 (17:38 +0200)
Old HP LaserJet printers have a firmware bug which makes them not
working with Ghostscript's PostScript output, so in pdftops() we
switch to Poppler for them.

We consider an old LaserJet every "HP LaserJet XXXXY" printer with
XXXX being a number (not preceded by a letter), typically 1-4 digits
and Y being 0-2 letters, no separated from the numbers by a space.

Unfortunately, we checked only whether after "LaserJet" comes a number
and not the rest. This made also modern printers with names like "HP
LaserJet 500 color M551" considered old and these modern printers have
another PostScript interpreter bug which makes them not print some
files with Poppler, so they need Ghostscript's PostScript output.

Therefore we refine the check for the old-LaserJet quirk to see
whether after the number are extra words and if so, this is again a
modern printer and we do not switch to Poppler.

See https://bugs.launchpad.net/bugs/1967816

cupsfilters/pdftops.c

index 900d3b1a25cbc9de0761d913cab80e3df2d8c4af..1e8f5f03ba4f14856d41de3105d7ccec88f96e8c 100644 (file)
@@ -491,12 +491,17 @@ pdftops(int inputfd,         /* I - File descriptor input stream */
        if (isspace(*ptr)) continue;
        if (isdigit(*ptr))
        {
-         if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
-                      "pdftops: Switching to Poppler's pdftops instead of "
-                      "Ghostscript for old HP LaserJet (\"LaserJet "
-                      "<number>\", no letters before <number>) printers to "
-                      "work around bugs in the printer's PS interpreters");
-         renderer = PDFTOPS;
+         while (*ptr && isalnum(*ptr)) ptr ++;
+         if (!*ptr) /* End of string, no further word */
+         {
+           if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
+                        "pdftops: Switching to Poppler's pdftops instead of "
+                        "Ghostscript for old HP LaserJet (\"LaserJet "
+                        "<number>\", no letters before <number>, no "
+                        "additional words after <number>) printers to "
+                        "work around bugs in the printer's PS interpreters");
+           renderer = PDFTOPS;
+         }
        }
        break;
       }