Bug 688695

Summary: run together endobj and next object fails
Product: Ghostscript Reporter: Tor Andersson <tor.andersson>
Component: PDF InterpreterAssignee: Ray Johnston <ray.johnston>
Status: NOTIFIED FIXED    
Severity: enhancement    
Priority: P2    
Version: master   
Hardware: All   
OS: MacOS X   
Customer: 580 Word Size: ---
Attachments: corrupt pdf file that used to work

Description Tor Andersson 2006-05-14 05:55:12 UTC
The PDF parser has become more strict about a kind of corruption
where the endobj keyword is run together
with the following object number. Here is an excerpt from
a PDF file:

>> ^M>> ^Mendobj75 0 obj  <</Length 76 0 R /Filter /FlateDecode >>  stream^Mx~\

This kind of corrupt PDF used to work in 8.51 but causes an
Error: /undefined in /BXlevel in 8.53 and HEAD.
Comment 1 Tor Andersson 2006-05-14 06:01:42 UTC
Created attachment 2192 [details]
corrupt pdf file that used to work

objects that are written in the second 'update' are sometimes run together.
for instance, the first instance of object 1 0 is fine, but the second instance
is
missing whitespace after the endobj keyword.
Comment 2 Tor Andersson 2006-05-14 06:06:41 UTC
GS 8.51 does not crash, but does complain about the file having errors,
and does not use any of the objects that were added in the incremental
update that introduced the corruption.
Comment 3 Ray Johnston 2006-05-17 09:44:15 UTC
Change priority to P2 (customer level). 
Comment 4 Ray Johnston 2006-05-17 13:04:55 UTC
Change committed to allow yet another broken PDF that Acrobat Reader handles
without griping to be handled by Ghostscript. YUK!

--- lib/pdf_base.ps     (revision 6779)
+++ lib/pdf_base.ps     (revision 6781)
@@ -165,7 +165,14 @@
     dup dup dup /true eq exch /false eq or exch /null eq or {
       exch pop exch pop //systemdict exch get
     } {
-      .pdftokenerror
+      % Hackish fix to detect missing whitespace after "endobj". Yet another
+      % problem that (you guessed it!) Adobe Acrobat ignores silently
+      256 string cvs (endobj) anchorsearch {
+        (   **** Missing whitespace after 'endobj'.\n) pdfformaterror
+        exch pop cvn get exch pop exec
+      } {
+        .pdftokenerror
+      } ifelse
     } ifelse
   } ifelse
 } bind def