From ba1ca81f9928aa75464a813ae26c166edd52a695 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 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pdf.c b/pdf.c
index c2c77fa..88453b7 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)"),
-- 
GitLab