From 3036b841bd960d7e5ee4e855821bef4ece1bdfb2 Mon Sep 17 00:00:00 2001 From: Ken Sharp Date: Mon, 12 Dec 2022 11:40:47 +0000 Subject: GhostPDF - add some warnings to approximate the old interpreter If the %PDF-x.y version has non-white space characters between the minor version number and the EOL the old interpreter issued a warning, we now do similarly. If an annotation entry in the Page dictionary was not a dictionary the old interpreter raised a warning, we were silently ignoring it. --- pdf/ghostpdf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'pdf/ghostpdf.c') diff --git a/pdf/ghostpdf.c b/pdf/ghostpdf.c index e6751155a..b9444cefc 100644 --- a/pdf/ghostpdf.c +++ b/pdf/ghostpdf.c @@ -1339,6 +1339,18 @@ int pdfi_set_input_stream(pdf_context *ctx, stream *stm) } else { ctx->HeaderVersion = version; + s += 5; + while (((*s >= '0' && *s <= '9') || *s == '.') && *s != 0x00) + s++; + while (*s != 0x00) { + if (*s == 0x09 || *s== 0x0c || *s == 0x20) { + s++; + continue; + } + if (*s != 0x0A && *s != 0x0D) + pdfi_set_warning(ctx, 0, NULL, W_PDF_VERSION_NO_EOL, "pdfi_set_input_stream", (char *)"%% PDF version not immediately followed with EOL\n"); + break; + } } if (ctx->args.pdfdebug) dmprintf1(ctx->memory, "%% Found header, PDF version is %f\n", ctx->HeaderVersion); -- cgit v1.2.1