From e98299546f5c5c3c22388d16507f8b5e61a5f280 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 12 Nov 2026 11:26:10 -0500 Subject: [PATCH] crs: a repeated name keeps its first value, as craft-metadata reads it craft-metadata #1042 keeps the first text-bearing value of a repeated property so a blank repeat cannot hide a location, but craft-crs's doc comment and test still claimed the last repeat wins. The workspace-wide test job has been red since it landed because of that assertion. --- crates/crs/src/lib.rs | 3 ++- crates/crs/src/tests.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/crs/src/lib.rs b/crates/crs/src/lib.rs index 2585bc605..6feae22fd 100644 --- a/crates/crs/src/lib.rs +++ b/crates/crs/src/lib.rs @@ -74,7 +74,8 @@ impl Value { } /// The `crs:` settings of a packet, by name without the prefix (`Exposure2012`). Where a name -/// occurs more than once (in several `rdf:Description`s), the last one is kept. +/// occurs more than once (in several `rdf:Description`s), the first text-bearing value is kept, +/// as [`craft_metadata::parse_xmp`] reads every packet: a blank repeat must not hide it. #[derive(Clone, Debug, Default, PartialEq)] pub struct Settings { pub entries: BTreeMap, diff --git a/crates/crs/src/tests.rs b/crates/crs/src/tests.rs index d850e6c3b..3faab6a2a 100644 --- a/crates/crs/src/tests.rs +++ b/crates/crs/src/tests.rs @@ -78,10 +78,14 @@ fn structures_other_prefixes_and_other_namespaces() { assert_eq!(masks.items().first().and_then(|m| m.field("crs:What")).and_then(XmpValue::text), Some("Correction")); assert_eq!(s.get("Empty"), Some(&Value::Text(String::new()))); assert_eq!(s.get("format"), None); - // The last value of a repeated name wins. + // A repeated name keeps its first value, as `craft_metadata` reads every packet: an empty + // repeat must not hide what an earlier description said. let second = format!("/>"); let twice = with("crs:Texture=\"1\"").replace("/>", &second); - assert_eq!(Settings::parse(twice.as_bytes()).unwrap().text("Texture"), Some("2")); + assert_eq!(Settings::parse(twice.as_bytes()).unwrap().text("Texture"), Some("1")); + let blank = format!("/>"); + let hiding = with("crs:Texture=\"1\"").replace("/>", &blank); + assert_eq!(Settings::parse(hiding.as_bytes()).unwrap().text("Texture"), Some("1"), "a blank repeat does not win"); } #[test]