diff --git a/pdf.c b/pdf.c index c2c77fa2671c7d03fc13904907ce5c107f37c1ba..88453b75900dc45e5fa76a64c24eb428ea890483 100644 --- a/pdf.c +++ b/pdf.c @@ -704,7 +704,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)); + 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)"),