From b464b1ecad9d0ddd6a2b8d935ba360e7982d6b74 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 08:08:13 -0800 Subject: [PATCH] PDF: check that the PDF/X-4 XMP packet stays well-formed The PDF/X test now asserts that the outer description declares the pdfxid namespace exactly once, and that the edited packet parses with the strict XML parser that File Info uses to read it back. --- crates/pdf/src/tests/pdfx.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/pdf/src/tests/pdfx.rs b/crates/pdf/src/tests/pdfx.rs index 6f9bce01f1..f9d6e90b5a 100644 --- a/crates/pdf/src/tests/pdfx.rs +++ b/crates/pdf/src/tests/pdfx.rs @@ -127,6 +127,9 @@ fn each_standard_writes_its_header_output_intent_boxes_and_identification() { // Validators expect the version property to inherit its namespace from the description. assert_eq!(attributes.contains(r#"xmlns:pdfxid="http://www.npes.org/pdfx/ns/id/""#), is_pdfx4, "{standard:?}: {attributes}"); assert_eq!(xmp_value(&xmp, "pdfxid:GTS_PDFXVersion"), is_pdfx4.then_some("PDF/X-4"), "{standard:?}"); + // The edited packet is still well-formed XML: the namespace is declared once. + assert_eq!(attributes.matches("xmlns:pdfxid=").count(), usize::from(is_pdfx4), "{standard:?}: {attributes}"); + assert!(craft_xml::Options::default().strict().parse(xmp.as_bytes()).is_ok(), "{standard:?}: {xmp}"); assert_eq!(t.contains("False"), standard == Standard::PdfX4); assert!(!t.contains("/Encrypt"), "{standard:?}"); // The file reads back.