diff --git a/crates/preflight/src/tests.rs b/crates/preflight/src/tests.rs
index b18d033c9e..e2a160904f 100644
--- a/crates/preflight/src/tests.rs
+++ b/crates/preflight/src/tests.rs
@@ -550,6 +550,13 @@ fn xmp_simple_values_have_their_lexical_forms() {
assert!(element("pdf:Trapped", "True").is_empty());
// rdf:resource makes a URI, which only a text type takes.
assert_eq!(mistyped(r#">"#), ["crs:Contrast"]);
+ // A GUID is a simple value but not a URI (ISO 16684-1 8.2.2.3).
+ assert!(element("xmpMM:DocumentID", "uuid:1234").is_empty());
+ assert_eq!(mistyped(r#">"#), ["xmpMM:DocumentID"]);
+ assert_eq!(
+ mistyped(r#">"#),
+ ["xmpMM:DerivedFrom"]
+ );
}
/// PDF/A-2 6.6.2.3.1, arrays: the kind, every item, and the languages of a language alternative.
@@ -651,6 +658,18 @@ fn xmp_value_types_are_reported_by_verify() {
]
);
assert!(found.iter().all(|i| !i.fixable));
+ // A UTF-16 packet, either byte order, is read.
+ for big in [true, false] {
+ let xmp = format!(
+ r#""#
+ );
+ let mut data = if big { vec![0xFE, 0xFF] } else { vec![0xFF, 0xFE] };
+ data.extend(xmp.encode_utf16().flat_map(|u| if big { u.to_be_bytes() } else { u.to_le_bytes() }));
+ let hex: String = data.iter().map(|b| format!("{b:02X}")).collect();
+ let stream = format!("<< /Type /Metadata /Subtype /XML /Filter /ASCIIHexDecode /Length {} >>\nstream\n{hex}>\nendstream", hex.len() + 1);
+ let doc = build(&["<< /Type /Catalog /Pages 2 0 R /Metadata 3 0 R >>", "<< /Type /Pages /Kids [] /Count 0 >>", &stream], "");
+ assert_eq!(issues(&doc).len(), 1, "big-endian: {big}");
+ }
// A metadata stream of a page counts as well as the catalog's.
let good = metadata(r#"crs:Contrast="5""#);
let doc = build(
diff --git a/crates/preflight/src/xmp_types.rs b/crates/preflight/src/xmp_types.rs
index d11c947926..55f542929c 100644
--- a/crates/preflight/src/xmp_types.rs
+++ b/crates/preflight/src/xmp_types.rs
@@ -33,9 +33,11 @@ const XML: &str = "http://www.w3.org/XML/1998/namespace";
/// A value type.
#[derive(Debug, Clone, Copy)]
enum Ty {
- /// Any simple value: Text and the types derived from it (AgentName, Choice of Text, GUID,
- /// Locale, MIMEType, ProperName, RenditionClass, URI, URL, XPath, and the like).
+ /// Any simple value: Text and the types derived from it (AgentName, Choice of Text, Locale,
+ /// MIMEType, ProperName, RenditionClass, URI, URL, XPath, and the like).
Text,
+ /// A GUID: any simple value, but not a URI (ISO 16684-1 8.2.2.3), so not an `rdf:resource`.
+ Guid,
Integer,
Real,
Boolean,
@@ -113,7 +115,7 @@ const THUMBNAIL: &[Field] = &[(XMP_G_IMG, "format", Text), (XMP_G_IMG, "height",
const RESOURCE_EVENT: &[Field] = &[
(ST_EVT, "action", Text),
(ST_EVT, "changed", Text),
- (ST_EVT, "instanceID", Text),
+ (ST_EVT, "instanceID", Ty::Guid),
(ST_EVT, "parameters", Text),
(ST_EVT, "softwareAgent", Text),
(ST_EVT, "when", Date),
@@ -121,10 +123,10 @@ const RESOURCE_EVENT: &[Field] = &[
/// ISO 16684-1 Table 3 and Part 2 Table 9.
const RESOURCE_REF: &[Field] = &[
(ST_REF, "alternatePaths", Ty::Seq(&Text)),
- (ST_REF, "documentID", Text),
+ (ST_REF, "documentID", Ty::Guid),
(ST_REF, "filePath", Text),
(ST_REF, "fromPart", Text),
- (ST_REF, "instanceID", Text),
+ (ST_REF, "instanceID", Ty::Guid),
(ST_REF, "lastModifyDate", Date),
(ST_REF, "manager", Text),
(ST_REF, "managerVariant", Text),
@@ -249,16 +251,16 @@ const SCHEMAS: &[Schema] = &[
prefix: "xmpMM",
properties: &[
("DerivedFrom", Ty::Struct(RESOURCE_REF)),
- ("DocumentID", Text),
+ ("DocumentID", Ty::Guid),
("History", Ty::Seq(&Ty::Struct(RESOURCE_EVENT))),
("Ingredients", Ty::Bag(&Ty::Struct(RESOURCE_REF))),
- ("InstanceID", Text),
+ ("InstanceID", Ty::Guid),
("ManagedFrom", Ty::Struct(RESOURCE_REF)),
("Manager", Text),
("ManageTo", Text),
("ManageUI", Text),
("ManagerVariant", Text),
- ("OriginalDocumentID", Text),
+ ("OriginalDocumentID", Ty::Guid),
("Pantry", Ty::Bag(&Ty::AnyStruct)),
("RenditionClass", Text),
("RenditionParams", Text),
@@ -461,7 +463,7 @@ pub(crate) fn mistyped_in(objs: &[(ObjRef, std::sync::Arc