fix printing for PDF+PJL drivers

This commit is contained in:
Zdenek Dohnal 2023-08-08 08:47:30 +02:00
parent 66ffabb030
commit 0d2377cf37
2 changed files with 155 additions and 1 deletions

View File

@ -0,0 +1,149 @@
From 30b35cc751bc312a1f82db849b1c80dbd8d32aa4 Mon Sep 17 00:00:00 2001
From: Till Kamppeter <till.kamppeter@gmail.com>
Date: Sat, 5 Aug 2023 19:15:16 +0200
Subject: [PATCH] Decode "JCLToPDFInterpreter" value in ppdEmitJCLPDF()
In ppdEmitJCLPDF() the "JCLToPDFInterpreter" value from the PPD file
is read out without decoding, producing broken PJL before the PDF
print data output for "classic" (non-driverless) PDF printing.
Also promoted the static function "ppd_decode()" of ppd/ppd.c into
the API function "ppdDecode()".
Fixes #24.
---
ppd/ppd-emit.c | 5 ++++-
ppd/ppd.c | 23 +++++++++++------------
ppd/ppd.h | 1 +
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/ppd/ppd-emit.c b/ppd/ppd-emit.c
index a3ea6f12..72c42861 100644
--- a/ppd/ppd-emit.c
+++ b/ppd/ppd-emit.c
@@ -386,7 +386,7 @@ ppdEmitJCLPDF(ppd_file_t *ppd, // I - PPD file record
// collate?
{
ppd_attr_t *attr; // PPD attribute
- const char *jcl_pdf = NULL;
+ char *jcl_pdf = NULL;
char *ptr; // Pointer into JCL string
char temp[65], // Local title string
displaymsg[33]; // Local display string
@@ -403,7 +403,10 @@ ppdEmitJCLPDF(ppd_file_t *ppd, // I - PPD file record
jcl_pdf = ppd->jcl_pdf;
#else
if ((attr = ppdFindAttr(ppd, "JCLToPDFInterpreter", NULL)) != NULL)
+ {
jcl_pdf = attr->value;
+ ppdDecode(jcl_pdf); // Decode quoted string
+ }
#endif
if ((!ppd->jcl_ps && hw_copies < 0) ||
diff --git a/ppd/ppd.c b/ppd/ppd.c
index 4354efc7..a8c47810 100644
--- a/ppd/ppd.c
+++ b/ppd/ppd.c
@@ -70,7 +70,6 @@ static int ppd_compare_choices(ppd_choice_t *a, ppd_choice_t *b);
static int ppd_compare_coptions(ppd_coption_t *a,
ppd_coption_t *b);
static int ppd_compare_options(ppd_option_t *a, ppd_option_t *b);
-static int ppd_decode(char *string);
static void ppd_free_filters(ppd_file_t *ppd);
static void ppd_free_group(ppd_group_t *group);
static void ppd_free_option(ppd_option_t *option);
@@ -872,23 +871,23 @@ ppdOpenWithLocalization(
else if (!strcmp(keyword, "JCLBegin"))
{
ppd->jcl_begin = strdup(string);
- ppd_decode(ppd->jcl_begin); // Decode quoted string
+ ppdDecode(ppd->jcl_begin); // Decode quoted string
}
else if (!strcmp(keyword, "JCLEnd"))
{
ppd->jcl_end = strdup(string);
- ppd_decode(ppd->jcl_end); // Decode quoted string
+ ppdDecode(ppd->jcl_end); // Decode quoted string
}
else if (!strcmp(keyword, "JCLToPSInterpreter"))
{
ppd->jcl_ps = strdup(string);
- ppd_decode(ppd->jcl_ps); // Decode quoted string
+ ppdDecode(ppd->jcl_ps); // Decode quoted string
}
#if HAVE_CUPS_3_X
else if (!strcmp(keyword, "JCLToPDFInterpreter"))
{
ppd->jcl_pdf = strdup(string);
- ppd_decode(ppd->jcl_pdf); // Decode quoted string
+ ppdDecode(ppd->jcl_pdf); // Decode quoted string
}
#endif
else if (!strcmp(keyword, "AccurateScreensSupport"))
@@ -1164,7 +1163,7 @@ ppdOpenWithLocalization(
choice->code = strdup(string);
if (custom_option->section == PPD_ORDER_JCL)
- ppd_decode(choice->code);
+ ppdDecode(choice->code);
}
//
@@ -1628,7 +1627,7 @@ ppdOpenWithLocalization(
// Fix up the text...
//
- ppd_decode(sptr);
+ ppdDecode(sptr);
//
// Find/add the group...
@@ -2079,7 +2078,7 @@ ppdOpenWithLocalization(
strlcpy(choice->text, name, sizeof(choice->text));
if (option->section == PPD_ORDER_JCL)
- ppd_decode(string); // Decode quoted string
+ ppdDecode(string); // Decode quoted string
choice->code = string;
string = NULL; // Don't add as an attribute below
@@ -2583,11 +2582,11 @@ ppd_compare_options(ppd_option_t *a, // I - First option
//
-// 'ppd_decode()' - Decode a string value...
+// 'ppdDecode()' - Decode a string value with hex-encoded characters
//
-static int // O - Length of decoded string
-ppd_decode(char *string) // I - String to decode
+int // O - Length of decoded string
+ppdDecode(char *string) // I - String to decode
{
char *inptr, // Input pointer
*outptr; // Output pointer
@@ -3415,7 +3414,7 @@ ppd_read(cups_file_t *fp, // I - File to read from
}
*textptr = '\0';
- textlen = ppd_decode(text);
+ textlen = ppdDecode(text);
if (textlen > PPD_MAX_TEXT && pg->ppd_conform == PPD_CONFORM_STRICT)
{
diff --git a/ppd/ppd.h b/ppd/ppd.h
index 64933091..85a0d317 100644
--- a/ppd/ppd.h
+++ b/ppd/ppd.h
@@ -721,6 +721,7 @@ extern int ppdResolveConflicts(ppd_file_t *ppd,
cups_option_t **options);
// **** New in libppd 2.0.0: Formerly CUPS-private functions ****
+extern int ppdDecode(char *string);
extern int ppdConvertOptions(ipp_t *request,
ppd_file_t *ppd,
ppd_cache_t *pc,
--
2.41.0

View File

@ -8,7 +8,7 @@
Name: libppd
Epoch: 1
Version: 2.0~rc2
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Library for retro-fitting legacy printer drivers
# the CUPS exception text is the same as LLVM exception, so using that name with
@ -24,6 +24,8 @@ Source0: %{URL}/releases/download/%{upstream_version}/%{name}-%{upstream_
Patch0001: libppd-disable-testppdfile.patch
# https://github.com/OpenPrinting/libppd/pull/21
Patch0002: 0001-ppd-ppd-ipp.c-Use-make-when-constructing-printer-mak.patch
# https://github.com/OpenPrinting/libppd/commit/30b35cc751bc312a1f82db849b1c80dbd8d32aa4
Patch0003: 0001-Decode-JCLToPDFInterpreter-value-in-ppdEmitJCLPDF.patch
# for autogen.sh
@ -196,6 +198,9 @@ rm -rf %{buildroot}%{_datadir}/ppdc
%endif
%changelog
* Tue Aug 08 2023 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.0~rc2-3
- fix printing for PDF+PJL drivers
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1:2.0~rc2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild