libspectre does not handle correctly when a FAKE %%EOF in the middle of a ps document
Submitted by Flex Liu
Assigned to Carlos Campos @carlosgc
Description
Created attachment 125346 the ps document include a FAKE EOF comment in the middle of the file.
I have some old ps documents been created by gle 3.3h, it include a FAKE EOF comment in the middle of the file, I found libspectre could not handle this correctly, it cause evince or okular doesn't display the ps document correctly.
I found these code in libspectre: libspectre/ps.c 401 int respect_eof; /* Derived from the scanstyle argument. 402 If set to 0 EOF comments will be ignored, 403 if set to 1 they will be taken seriously. 404 Purpose; Out there are many documents which 405 include other DSC conforming documents without 406 without enclosing them by 'BeginDocument' and 407 'EndDocument' comments. This may cause fake EOF 408 comments to appear in the body of a page. 409 Similarly, if respect_eof is set to false 410 'Trailer' comments are ignored except of the 411 last one found in the document. 412 / 413 int ignore_dsc; / Derived from scanstyle. 414 If set the document structure will be ignored. 415 */ 416 BEGINMESSAGE(psscan) 417 418 respect_eof = (scanstyle & SCANSTYLE_IGNORE_EOF) ? 0 : 1; 419 ignore_dsc = (scanstyle & SCANSTYLE_IGNORE_DSC) ? 1 : 0;
libspectre/ps.h 150 #define SCANSTYLE_NORMAL 0 151 #define SCANSTYLE_IGNORE_EOF (1<<0) 152 #define SCANSTYLE_IGNORE_DSC (1<<1)
So, why the default value of SCANSTYLE_NORMAL is 0, it cause respect_eof = 1, the FAKE EOF comment will interrupt the document. is it any compatibility issue here? thanks.
Attachment 125346, "the ps document include a FAKE EOF comment in the middle of the file.":
outfile.ps