Blame SOURCES/ghostscript-fix-DSC-comment-parsing.patch

bb3194
From: Ken Sharp <ken.sharp@artifex.com>
bb3194
Date: Fri, 21 Sep 2018 14:28:15 +0000 (+0100)
bb3194
Subject: pdfwrite - fix DSC comment parsing
bb3194
bb3194
pdfwrite - fix DSC comment parsing
bb3194
bb3194
This may affect other DSC parsing utilities. For some reason double
bb3194
comment (%%) marks are being interpreted 'sometimes' in gs_init.ps
bb3194
as DSC comments. This only happens when reading the init files from disk
bb3194
becuase the ROM file system strips comments.
bb3194
bb3194
Passing these to pdfwrite causes it to drop later DSC comments, such
bb3194
as %%Title: and %%Creator: which meant the information wasn't being
bb3194
embedded in the document information dictionary.
bb3194
bb3194
Fix by converting double %% to single % comments, document this in the
bb3194
header of gs_init.ps.
bb3194
bb3194
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=f31702b38fba21153e26c3417c838618e7cfd16f
bb3194
---
bb3194
bb3194
diff -up ghostscript-9.07/Resource/Init/gs_init.ps.comment_fix ghostscript-9.07/Resource/Init/gs_init.ps
79ccdd
--- ghostscript-9.07/Resource/Init/gs_init.ps.comment_fix	2019-02-28 11:02:59.540694185 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/gs_init.ps	2019-02-28 11:05:31.182710227 +0100
bb3194
@@ -20,6 +20,11 @@
bb3194
 %	%% Replace <n> <file(s)>
bb3194
 % indicate places where the next <n> lines should be replaced by
bb3194
 % the contents of <file(s)>, when creating a single merged init file.
bb3194
+%
bb3194
+% For reasons not clear to me, some cases of %% are being treated as
bb3194
+% DSC comments when (and only when) the resource files are disk based
bb3194
+% This can kill DSC parsing for pdfwrite at least, so avoid using
bb3194
+% double % comments in this file.
bb3194
 
bb3194
 % The interpreter can call out to PostScript code.  All procedures
bb3194
 % called in this way, and no other procedures defined in these
bb3194
@@ -2132,22 +2137,22 @@ SAFER { .setsafe } if
bb3194
 
bb3194
 /UndefinePostScriptOperators {
bb3194
 
79ccdd
-  %% This list is of Display PostScript operators. We believe that Display PostScript
79ccdd
-  %% was never fully implemented and the only known user, GNUStep, is no longer
79ccdd
-  %% using it. So lets remove it.
79ccdd
+  % This list is of Display PostScript operators. We believe that Display PostScript
79ccdd
+  % was never fully implemented and the only known user, GNUStep, is no longer
79ccdd
+  % using it. So lets remove it.
79ccdd
   [
79ccdd
   /condition /currentcontext /detach /.fork /join /.localfork /lock /monitor /notify
79ccdd
   /wait /yield /.currentscreenphase /.setscreenphase /.image2 /eoviewclip /initviewclip
79ccdd
   /viewclip /viewclippath /defineusername
79ccdd
-  %% NeXT DPS extensions
79ccdd
+  % NeXT DPS extensions
79ccdd
   /currentalpha /setalpha /.alphaimage /composite /compositerect /dissolve /sizeimagebox /.sizeimageparams
79ccdd
   ]
79ccdd
   {systemdict exch .forceundef} forall
bb3194
 
79ccdd
-  %% This list is of operators which no longer appear to be used, and which we do not believe
79ccdd
-  %% to have any real use. For now we will undefine the operstors so they cannot easily be used
79ccdd
-  %% but can be easily restored (just delete the name from the list in the array). In future
79ccdd
-  %% we may remove the operator and the code implementation entirely.
79ccdd
+  % This list is of operators which no longer appear to be used, and which we do not believe
79ccdd
+  % to have any real use. For now we will undefine the operstors so they cannot easily be used
79ccdd
+  % but can be easily restored (just delete the name from the list in the array). In future
79ccdd
+  % we may remove the operator and the code implementation entirely.
79ccdd
   [
79ccdd
   /.bitadd /.charboxpath /.cond /.runandhide /.popdevicefilter
79ccdd
   /.execfile /.filenamesplit /.file_name_parent
bb3194
@@ -2156,15 +2161,15 @@ SAFER { .setsafe } if
79ccdd
   /.currentlimitclamp /.dotorientation /.setaccuratecurves /.setcurvejoin /.setdashadapt /.setdotorientation
79ccdd
   /.setlimitclamp /.currentscreenlevels /.dashpath /.pathbbox /.identeq /.identne /.tokenexec /.forgetsave /.pantonecallback
bb3194
 
79ccdd
-  %% Used by our own test suite files
79ccdd
-  %%/.setdotlength % Bug687720.ps
79ccdd
+  % Used by our own test suite files
79ccdd
+  %/.setdotlength % Bug687720.ps
79ccdd
   ]
79ccdd
   {systemdict exch .forceundef} forall
bb3194
 
79ccdd
-  %% This list of operators are used internally by various parts of the Ghostscript startup code.
79ccdd
-  %% Since each operator is a potential security vulnerability, and any operator listed here
79ccdd
-  %% is not required once the initislisation is complete and functions are bound, we undefine
79ccdd
-  %% the ones that aren't needed at runtime.
79ccdd
+  % This list of operators are used internally by various parts of the Ghostscript startup code.
79ccdd
+  % Since each operator is a potential security vulnerability, and any operator listed here
79ccdd
+  % is not required once the initislisation is complete and functions are bound, we undefine
79ccdd
+  % the ones that aren't needed at runtime.
79ccdd
   [
79ccdd
   /.callinstall /.callbeginpage /.callendpage
79ccdd
   /.currentstackprotect /.setstackprotect /.errorexec /.finderrorobject /.installsystemnames /.bosobject /.fontbbox
79ccdd
@@ -2236,10 +2241,10 @@ SAFER { .setsafe } if
79ccdd
 } .bind executeonly def % must be bound and hidden for .forceundef
bb3194
 
bb3194
 /UndefinePDFOperators {
79ccdd
-  %% This list of operators are used internally by various parts of the Ghostscript PDF interpreter.
79ccdd
-  %% Since each operator is a potential security vulnerability, and any operator listed here
79ccdd
-  %% is not required once the initislisation is complete and functions are bound, we undefine
79ccdd
-  %% the ones that aren't needed at runtime.
79ccdd
+  % This list of operators are used internally by various parts of the Ghostscript PDF interpreter.
79ccdd
+  % Since each operator is a potential security vulnerability, and any operator listed here
79ccdd
+  % is not required once the initislisation is complete and functions are bound, we undefine
79ccdd
+  % the ones that aren't needed at runtime.
79ccdd
   [
79ccdd
   /.pdfawidthshow /.pdfwidthshow
79ccdd
   /.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent
79ccdd
@@ -2380,8 +2385,8 @@ currentdict /.shadingtypes .undef
bb3194
 currentdict /.wheredict .undef
bb3194
 currentdict /.renderingintentdict .undef
bb3194
 
bb3194
-%% If we are using DELAYBIND we have to defer the undefinition
bb3194
-%% until .bindnow.
bb3194
+% If we are using DELAYBIND we have to defer the undefinition
bb3194
+% until .bindnow.
bb3194
 DELAYBIND not {
bb3194
   SAFER {
bb3194
     //systemdict /SAFERUndefinePostScriptOperators get exec
79ccdd
@@ -2408,7 +2413,7 @@ systemdict /superexec .knownget {
79ccdd
   systemdict /superexec .undef
bb3194
 } if
bb3194
 
bb3194
-%% Can't remove this one until the last minute :-)
bb3194
+% Can't remove this one until the last minute :-)
bb3194
 systemdict /.undef .undef
bb3194
 
bb3194
 WRITESYSTEMDICT not { systemdict readonly pop } if