[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1808-g4859047
[email protected] (Chris Liddell) Tue, 5 Nov 2019 10:42:25 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via 485904772c5f0aa1140032746e5a0abfc40f4cef (commit)
via 94d8955cb7725eb5f3557ddc02310c76124fdd1a (commit)
via 39b4cdb491c3e09434f5d2b9c334a898fb569850 (commit)
via d1eac80695b2c6f2a85942a82518715549541969 (commit)
from 27409d99b069e434c6863f43456cf8985bbdf7f8 (commit)
----------------------------------------------------------------------
commit 485904772c5f0aa1140032746e5a0abfc40f4cef
Author: Chris Liddell <[email protected]>
Date: Tue Nov 5 09:45:27 2019 +0000
Bug 701841: remove .forceput from /.charkeys
When loading Type 1 or Truetype fonts from disk, we attempt to extend the glyph
name table to include all identifiable glyph names from the Adobe Glyph List.
In the case of Type 1 fonts, the font itself (almost always) marks the
CharStrings dictionary as read-only, hence we have to use .forceput for that
case.
But for Truetype fonts, the CharStrings dictionary is created internally and is
not read-only until *after* we have fully populated it (including the extended
glyph names from the AGL), hence there is no need for .forceput, and no need to
carry the security risk of using it.
Replace with regular put.
diff --git a/Resource/Init/gs_ttf.ps b/Resource/Init/gs_ttf.ps
index 74043d1..6be8fe9 100644
--- a/Resource/Init/gs_ttf.ps
+++ b/Resource/Init/gs_ttf.ps
@@ -1304,7 +1304,7 @@ currentdict /.pickcmap_with_no_xlatmap .undef
TTFDEBUG { (\n1 setting alias: ) print dup ==only
( to be the same as ) print 2 index //== exec } if
- 7 index 2 index 3 -1 roll exch .forceput
+ 7 index 2 index 3 -1 roll exch put
} forall
pop pop pop
}
@@ -1322,7 +1322,7 @@ currentdict /.pickcmap_with_no_xlatmap .undef
exch pop
TTFDEBUG { (\n2 setting alias: ) print 1 index ==only
( to use glyph index: ) print dup //== exec } if
- 5 index 3 1 roll .forceput
+ 5 index 3 1 roll put
//false
}
{
@@ -1339,7 +1339,7 @@ currentdict /.pickcmap_with_no_xlatmap .undef
{ % CharStrings(dict) isunicode(boolean) cmap(dict) RAGL(dict) gname(name) codep(integer) gindex(integer)
TTFDEBUG { (\3 nsetting alias: ) print 1 index ==only
( to be index: ) print dup //== exec } if
- exch pop 5 index 3 1 roll .forceput
+ exch pop 5 index 3 1 roll put
}
{
pop pop
@@ -1369,7 +1369,7 @@ currentdict /.pickcmap_with_no_xlatmap .undef
} ifelse
]
TTFDEBUG { (Encoding: ) print dup === flush } if
-} .bind executeonly odef % hides .forceput
+} .bind odef
% ---------------- CIDFontType 2 font loading ---------------- %
----------------------------------------------------------------------
commit 94d8955cb7725eb5f3557ddc02310c76124fdd1a
Author: Chris Liddell <[email protected]>
Date: Mon Nov 4 14:23:30 2019 +0000
Bug 701818: better handling of error during PS/PDF image
In the xps device, if an error occurred after xps_begin_image() but before
xps_image_end_image(), *if* the Postscript had called 'restore' as part of the
error handling, the image enumerator would have been freed (by the restore)
despite the xps device still holding a reference to it.
Simply changing to an allocator unaffected save/restore doesn't work because
the enumerator holds references to other objects (graphics state, color space,
possibly others) whose lifespans are inherently controlled by save/restore.
So, add a finalize method for the XPS device's image enumerator
(xps_image_enum_finalize()) which takes over cleaning up the memory it allocates
and also deals with cleaning up references from the device to the enumerator
and from the enumerator to the device.
diff --git a/devices/vector/gdevxps.c b/devices/vector/gdevxps.c
index 71ca1f7..5d98c28 100644
--- a/devices/vector/gdevxps.c
+++ b/devices/vector/gdevxps.c
@@ -152,9 +152,12 @@ typedef struct xps_image_enum_s {
gp_file *fid;
} xps_image_enum_t;
-gs_private_st_suffix_add4(st_xps_image_enum, xps_image_enum_t,
+static void
+xps_image_enum_finalize(const gs_memory_t *cmem, void *vptr);
+
+gs_private_st_suffix_add4_final(st_xps_image_enum, xps_image_enum_t,
"xps_image_enum_t", xps_image_enum_enum_ptrs,
- xps_image_enum_reloc_ptrs, st_vector_image_enum,
+ xps_image_enum_reloc_ptrs, xps_image_enum_finalize, st_vector_image_enum,
buffer, devc_buffer, pcs, pgs);
typedef struct gx_device_xps_s {
@@ -1424,6 +1427,11 @@ xps_finish_image_path(gx_device_vector *vdev)
const char *fmt;
gs_matrix matrix;
+ /* If an error occurs during an image, we can get here after the enumerator
+ * has been freed - if that's the case, just bail out immediately
+ */
+ if (xps->xps_pie == NULL)
+ return;
/* Path is started. Do the image brush image brush and close the path */
write_str_to_current_page(xps, "\t<Path.Fill>\n");
write_str_to_current_page(xps, "\t\t<ImageBrush ");
@@ -2214,17 +2222,6 @@ xps_image_end_image(gx_image_enum_common_t * info, bool draw_last)
code = xps_add_image_relationship(pie);
exit:
- if (pie->pcs != NULL)
- rc_decrement(pie->pcs, "xps_image_end_image (pcs)");
- if (pie->buffer != NULL)
- gs_free_object(pie->memory, pie->buffer, "xps_image_end_image");
- if (pie->devc_buffer != NULL)
- gs_free_object(pie->memory, pie->devc_buffer, "xps_image_end_image");
-
- /* ICC clean up */
- if (pie->icc_link != NULL)
- gsicc_release_link(pie->icc_link);
-
return code;
}
@@ -2485,3 +2482,23 @@ tiff_from_name(gx_device_xps *dev, const char *name, int big_endian, bool usebig
xps_tifsDummyUnmapProc);
return t;
}
+
+static void
+xps_image_enum_finalize(const gs_memory_t *cmem, void *vptr)
+{
+ xps_image_enum_t *xpie = (xps_image_enum_t *)vptr;
+ gx_device_xps *xdev = (gx_device_xps *)xpie->dev;
+
+ xpie->dev = NULL;
+ if (xpie->pcs != NULL)
+ rc_decrement(xpie->pcs, "xps_image_end_image (pcs)");
+ if (xpie->buffer != NULL)
+ gs_free_object(xpie->memory, xpie->buffer, "xps_image_end_image");
+ if (xpie->devc_buffer != NULL)
+ gs_free_object(xpie->memory, xpie->devc_buffer, "xps_image_end_image");
+
+ /* ICC clean up */
+ if (xpie->icc_link != NULL)
+ gsicc_release_link(xpie->icc_link);
+ xdev->xps_pie = NULL;
+}
----------------------------------------------------------------------
commit 39b4cdb491c3e09434f5d2b9c334a898fb569850
Author: Chris Liddell <[email protected]>
Date: Thu Oct 31 15:30:19 2019 +0000
Update docs for current state of transparency ops
diff --git a/doc/Language.htm b/doc/Language.htm
index 9050118..5f112a1 100644
--- a/doc/Language.htm
+++ b/doc/Language.htm
@@ -438,8 +438,15 @@ The garbage collector doesn't reclaim portions of arrays obtained with
<h3><a name="Graphics_and_text"></a>Graphics and text operators</h3>
-<h4><a name="Transparency"></a>Transparency</h4>
-
+<h4><u><a name="Transparency"></a>Transparency</u></h4>
+<p><b><u>NOTE:</u></b> The following paragraphs describe non-standard operators
+for accessing the PDF 1.4 and later transparent imaging model through Postscript.
+If used incorrectly, they can have unexpected side effects and result in undefined
+behavior. As a result, these operators are disabled when <a href="Use.htm#Safer"><b>SAFER</b></a>
+is in force (as it is by default from version 9.50 onwards). To utilise these operators
+you will either have to disable <code>SAFER</code> (<code>-dNOSAFER</code>) or use
+the command line parameter <code>-dALLOWPSTRANSPARENCY</code>. The latter will make
+the custom operators available, but leave the file access controls active.
<p>
Ghostscript provides a set of operators for implementing the transparency
and compositing facilities of PDF 1.4. These are defined only if the
@@ -460,6 +467,26 @@ shape.</p>
<h5><a name="Transparency_graphics_state_operators"></a>Graphics state
operators</h5>
+<p>Pushing the compositor device must be done before any other marking
+operations are made on the current page, and must be done per page.
+Popping the compositor should be done after the last marking operation
+of the page, and before the call to <code>showpage</code>. Any marking
+operations made after the compositor is popped will bypass the transparent
+imaging model, and may produce unexpected output.
+
+<dl>
+<dt><code><depth> .pushpdf14devicefilter -</code></dt>
+<dd>Installs the transparency compositor device into the graphics state. At
+present the <code>depth</code> parameter should always be zero (<b>Subject
+To Change.</b>)
+</dl>
+<dl>
+<dt><code>- .popdf14devicefilter -</code></dt>
+<dd>Removes (or, more accuracately, disables) the transparency compositor in
+graphics state.
+</dl>
+
+
<dl>
<dt><code><modename> .setblendmode -</code></dt>
<dd>Sets the blending mode in the graphics state. If the mode name is not
@@ -496,7 +523,7 @@ accumulate only a coverage value. Layers must be properly nested, i.e., the
'end' or 'discard' operator must match the corresponding 'begin' operator.</p>
<p>
-Beginning and ending layers must nest properly with respect to
+Beginning and ending groups must nest properly with respect to
<code>save</code> and <code>restore</code>: <code>save</code> and
<code>restore</code> do not save and restore the layer stack. Currently,
layers are not required to nest with respect to <code>gsave</code> and
----------------------------------------------------------------------
commit d1eac80695b2c6f2a85942a82518715549541969
Author: Chris Liddell <[email protected]>
Date: Thu Oct 31 10:19:01 2019 +0000
Add the ability to allow transparency ops in Postscript
-dALLOWPSTRANSPARENCY on the command line will prevent the undefining of the
non-standard gs Postscript transparency operators.
Driving these operators in the wrong way can cause undefined behavior, hence
not allowing them normally.
Also, use a better condition for dropping the transparency ops in:
examples/transparency_example.ps
diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
index 390ff79..6f0c230 100644
--- a/Resource/Init/gs_init.ps
+++ b/Resource/Init/gs_init.ps
@@ -197,6 +197,11 @@ currentdict /NOSAFERERRORS known
currentdict /SAFERERRORS known
} ifelse def
+currentdict /ALLOWPSTRANSPARENCY known not
+{
+ /ALLOWPSTRANSPARENCY //false def
+} if
+
currentdict /SHORTERRORS known /SHORTERRORS exch def
currentdict /TTYPAUSE known /TTYPAUSE exch def
currentdict /WRITESYSTEMDICT known /WRITESYSTEMDICT exch def
@@ -2204,11 +2209,6 @@ readonly def
/SAFERUndefinePostScriptOperators {
[
% Used by our own test suite files
- /.pushpdf14devicefilter % transparency-example.ps
- /.poppdf14devicefilter % transparency-example.ps
- /.setopacityalpha % transparency-example.ps
- /.setshapealpha % transparency-example.ps
- /.endtransparencygroup % transparency-example.ps
/.setdotlength % Bug687720.ps
/.sort /.setdebug /.mementolistnewblocks /getenv
/unread
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
index 09b7765..7c608c8 100644
--- a/Resource/Init/pdf_main.ps
+++ b/Resource/Init/pdf_main.ps
@@ -3557,24 +3557,33 @@ end % pdfdict
/.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent
/.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
/.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
-/.settextlinematrix /.currenttextlinematrix /.currenttextmatrix /.settextmatrix /.currentblendmode
-/.currentopacityalpha /.currentshapealpha /.currenttextknockout
-/.pushextendedgstate /.popextendedgstate /.begintransparencytextgroup
-/.endtransparencytextgroup /.begintransparencymaskgroup /.begintransparencymaskimage /.endtransparencymask /.image3x
-/.abortpdf14devicefilter /.pdfinkpath /.pdfFormName /.setstrokeconstantalpha
-/.setfillconstantalpha /.setalphaisshape /.currentalphaisshape
-/.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise
-/.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling /.setPDFfontsize /.currentPDFfontsize
-/.setdistillerparams
+/.settextlinematrix /.currenttextlinematrix /.currenttextmatrix /.settextmatrix /.pushextendedgstate
+/.popextendedgstate
-% Used by our own test suite files
-%/.pushpdf14devicefilter % transparency-example.ps
-%/.poppdf14devicefilter % transparency-example.ps
-%/.setopacityalpha % transparency-example.ps
-%/.setshapealpha % transparency-example.ps
-%/.endtransparencygroup % transparency-example.ps
+/.pdfinkpath /.pdfFormName /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
+/.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
+/.setPDFfontsize /.currentPDFfontsize /.setdistillerparams
% undefining these causes errors/incorrect output
-%/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /.setstrokeoverprint /.setfilloverprint
-%/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha
+%/.settextrenderingmode
] systemdict .undefinternalnames
+
+% The following are split out allowing control via ALLOWPSTRANSPARENCY command line param
+[
+ /.currentblendmode /.currentopacityalpha /.currentshapealpha /.currenttextknockout /.begintransparencytextgroup
+ /.endtransparencytextgroup /.begintransparencymaskgroup /.begintransparencymaskimage /.begintransparencypagegroup
+ /.endtransparencymask /.image3x /.abortpdf14devicefilter /.setfillconstantalpha /.setalphaisshape /.currentalphaisshape
+
+ % Used by our own test suite files
+ %/.pushpdf14devicefilter % transparency-example.ps
+ %/.poppdf14devicefilter % transparency-example.ps
+ %/.setopacityalpha % transparency-example.ps
+ %/.setshapealpha % transparency-example.ps
+ %/.endtransparencygroup % transparency-example.ps
+
+ % undefining these causes errors/incorrect output
+ %/.setblendmode /.begintransparencygroup /.settextknockout /.setstrokeoverprint /.setfilloverprint
+ %/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha
+ %/.setstrokeconstantalpha /.setfillconstantalpha /.setSMask /.currentSMask
+
+] systemdict dup /ALLOWPSTRANSPARENCY get {pop pop}{.undefinternalnames}ifelse
diff --git a/examples/transparency_example.ps b/examples/transparency_example.ps
index 82ffada..8120049 100644
--- a/examples/transparency_example.ps
+++ b/examples/transparency_example.ps
@@ -3,7 +3,7 @@
/PageUsesTransparency true def
-systemdict /.pushpdf14devicefilter known not
+systemdict /.setalphaisshape known not
{
(\n\n%%%% WARNING: Transparency operations ignored - probably due to using -dSAFER\n\n) print flush
/.pushpdf14devicefilter {pop} bind def
Summary of changes:
Resource/Init/gs_init.ps | 10 ++++-----
Resource/Init/gs_ttf.ps | 8 +++----
Resource/Init/pdf_main.ps | 45 ++++++++++++++++++++++++----------------
devices/vector/gdevxps.c | 43 ++++++++++++++++++++++++++------------
doc/Language.htm | 33 ++++++++++++++++++++++++++---
examples/transparency_example.ps | 2 +-
6 files changed, 97 insertions(+), 44 deletions(-)