From 711e1b9418a02c1dfd961c08faf4abf068513137 Mon Sep 17 00:00:00 2001 From: "plvines (corpora)" <paul.vines@baesystems.com> Date: Mon, 17 Feb 2020 14:28:45 +0000 Subject: [PATCH] Added relaxation/violation for missing %%EOF and/or startxref after internal (updated) xref-table + trailer --- pdf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pdf.c b/pdf.c index 9a1ce54..9ad84b3 100644 --- a/pdf.c +++ b/pdf.c @@ -710,9 +710,10 @@ init_parser(struct Env *aux) H_RULE(hdr_junk, VIOL(h_many1(h_butnot(h_ch_range(0, 255), objdef)), "Uncommented junk after header (severity=1)")); - H_RULE(tail, SEQ(body, h_optional(xr_td), startxr)); - // XXX the real world likes to omit 'startxr' from all but the - // last trailer. we should accept-and-warn in that case. + H_RULE(tail, SEQ(body, CHX(SEQ(h_optional(xr_td), startxr), + VIOL(SEQ(xr_td, OPT(SEQ(nl, KW("startxref"), nl, lws, nat, nl)), + OPT(nl), OPT(LIT("%%EOF")), OPT(nl)), + "Improper end of trailer - missing startxref and/or %%EOF (severity=5)")))); H_RULE(final_eof_junk, CHX(VIOL(SEQ(h_many1(nl), end), "Multiple newlines after final %%EOF (severity=4)"), VIOL(h_many1(h_butnot(h_ch_range(0, 255), LIT("%%EOF"))), "Data after final %%EOF (severity=7)"), -- GitLab