[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1711-gf03bac8
[email protected] (Ken Sharp) Mon, 30 Sep 2019 13:24:47 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via f03bac8ec2dabfff5583bf6afdd2b77f1885f8ef (commit)
from 77f79475fd0419d16f1efe7812a44a9720fef10b (commit)
----------------------------------------------------------------------
commit f03bac8ec2dabfff5583bf6afdd2b77f1885f8ef
Author: Ken Sharp <[email protected]>
Date: Mon Sep 30 13:40:35 2019 +0100
pdfwrite - don't honour /Producer key in DOCINFO pdfmark
Bug #701639 "pdfwrite should not honour the /Producer key in DOCINFO pdfmark"
The Producer in the document information dictionary (and XML Metadata)
is defined quite clearly as the application which produced the PDF file
from its native format.
Ghostscript uses the Producer key (if present in the pdfmark) to set
the Producer, but it should not do so. Adobe Acrobat Distiller (at
least the end user version) does not permit this value to be altered.
On reflection we can see why; in the case of a problem with a PDF file
its important to know which application created it, and we should not
let PostScript obscure that (we already do not pass the Producer
information on when the input is PDF).
The code did already attempt to overwrite any Producer string which
contained 'Distiller' (I have no idea why) and that code contained an
error which could lead to an invalid Document Information dictionary
being created.
This commit removes the ability for DOCINFO pdfmarks to alter the
Producer, which obviously fixes the bug.
However..... it is actually important for our commercial customers to
be able to set this value. A problem with a PDF file created by one of
our customer's products should be reported to that customer, not us, as
we will not be able to investigate the problem while our customer
should be able to. At the very least our customer will know how to
retrieve the configuration of Ghostscript being used.
So permit the commercial version of Ghostscript to set the /Producer
from a pdfmark.
diff --git a/devices/vector/gdevpdfm.c b/devices/vector/gdevpdfm.c
index 30cc1e1..6e018aa 100644
--- a/devices/vector/gdevpdfm.c
+++ b/devices/vector/gdevpdfm.c
@@ -1931,18 +1931,11 @@ pdfmark_DOCINFO(gx_device_pdf * pdev, gs_param_string * pairs, uint count,
*/
cos_dict_t *const pcd = pdev->Info;
int code = 0, i;
- gs_memory_t *mem = pdev->pdf_memory;
if (count & 1)
return_error(gs_error_rangecheck);
for (i = 0; code >= 0 && i < count; i += 2) {
const gs_param_string *pair = pairs + i;
- gs_param_string alt_pair[2];
- const byte *vdata; /* alt_pair[1].data */
- uint vsize; /* alt_pair[1].size */
- byte *str = 0;
-
- vsize = 0x0badf00d; /* Quiet compiler. */
if (pdev->CompatibilityLevel >= 2.0) {
if (!pdf_key_eq(pairs + i, "/ModDate") && !pdf_key_eq(pairs + i, "/CreationDate"))
@@ -1979,55 +1972,16 @@ pdfmark_DOCINFO(gx_device_pdf * pdev, gs_param_string * pairs, uint count,
}
}
if (pdf_key_eq(pairs + i, "/Producer")) {
- /*
- * If the string "Distiller" appears anywhere in the Producer,
- * replace the Producer (or the part after a " + ") with our
- * own name.
- */
string_match_params params;
-
- memcpy(alt_pair, pairs + i, sizeof(alt_pair));
- vdata = alt_pair[1].data;
- vsize = alt_pair[1].size;
params = string_match_params_default;
params.ignore_case = true;
- if (string_match(vdata, vsize, (const byte *)"*Distiller*",
- 11, ¶ms) ||
- string_match(vdata, vsize,
- (const byte *)"*\000D\000i\000s\000t\000i\000l\000l\000e\000r*",
- 20, ¶ms)
- ) {
- uint j;
- char buf[PDF_MAX_PRODUCER];
- int len;
- for (j = vsize; j > 0 && vdata[--j] != '+'; )
- DO_NOTHING;
- if (vsize - j > 2 && vdata[j] == '+') {
- ++j;
- while (j < vsize && vdata[j] == ' ')
- ++j;
- }
- /*
- * Replace vdata[j .. vsize) with our name. Note that both
- * vdata/vstr and the default producer string are enclosed
- * in ().
- */
- pdf_store_default_Producer(buf);
- len = strlen(buf) - 1;
- str = gs_alloc_string(mem, j + len, "Producer");
- if (str == 0)
- return_error(gs_error_VMerror);
- memcpy(str, vdata, j);
- memcpy(str + j, buf + 1, len);
- alt_pair[1].data = str;
- alt_pair[1].size = vsize = j + len;
- pair = alt_pair;
- }
- }
- code = pdfmark_put_pair(pcd, pair);
- if (str)
- gs_free_string(mem, str, vsize, "Producer");
+ if (!string_match((const byte *)GS_PRODUCTFAMILY, strlen(GS_PRODUCTFAMILY), (const byte *)"GPL Ghostscript", 15, ¶ms))
+ code = pdfmark_put_pair(pcd, pair);
+ } else
+ code = pdfmark_put_pair(pcd, pair);
+ if (code < 0)
+ break;
}
return code;
}
Summary of changes:
devices/vector/gdevpdfm.c | 60 ++++++-----------------------------------------
1 file changed, 7 insertions(+), 53 deletions(-)