diff --git a/crates/engine-core/src/cmd/file_cmds/info.rs b/crates/engine-core/src/cmd/file_cmds/info.rs index d8e72f42b3..20b080e909 100644 --- a/crates/engine-core/src/cmd/file_cmds/info.rs +++ b/crates/engine-core/src/cmd/file_cmds/info.rs @@ -106,13 +106,13 @@ fn rights_marked(xmp: &str) -> Option<&str> { // The existing Marked path retains its quote/whitespace and rewrite-span behavior. fn marked_attr(xmp: &str) -> Option<(usize, usize, &str)> { - tag_attr(xmp, "xmpRights:Marked") + tag_attr(xmp, "xmpRights:Marked", false) } /// Attribute form `prop="…"` with either quote and XML whitespace before the name and around `=`. /// Only names inside a tag count, not text in another attribute's value, element text, a comment /// or CDATA. The span includes the whitespace before the name, so rewriting removes what is read. -fn tag_attr<'a>(xmp: &'a str, prop: &str) -> Option<(usize, usize, &'a str)> { +fn tag_attr<'a>(xmp: &'a str, prop: &str, camera_only: bool) -> Option<(usize, usize, &'a str)> { // The tab title asks every frame, and packets can be megabytes: walk only when the name is there. if !xmp.contains(prop) { return None; @@ -124,7 +124,9 @@ fn tag_attr<'a>(xmp: &'a str, prop: &str) -> Option<(usize, usize, &'a str)> { (_, Some(q)) => quote = (c != q).then_some(q), (false, None) if c == b'<' => { let rest = &xmp[i..]; - let skip = [(""), ("")].into_iter().find(|(open, _)| rest.starts_with(open)); + let skip = [(""), (""), ("")] + .into_iter() + .find(|(open, _)| rest.starts_with(open) && (camera_only || *open != " i += rest.find(close).map_or(rest.len(), |e| e + close.len()) - 1, None => in_tag = true, @@ -271,7 +273,7 @@ fn date_text(s: &str) -> String { fn xmp_value(x: &str, prop: &str) -> Option { let v = match find_element(x, prop) { Some((_, _, inner)) => li_values(inner).into_iter().next(), - None => tag_attr(x, prop).map(|(_, _, v)| xml_unescape(v)), + None => tag_attr(x, prop, true).map(|(_, _, v)| xml_unescape(v)), }?; let v = v.trim().to_string(); (!v.is_empty()).then_some(v) diff --git a/crates/ui-egui/src/file_info_categories_tests.rs b/crates/ui-egui/src/file_info_categories_tests.rs index 39695b790c..0087628d29 100644 --- a/crates/ui-egui/src/file_info_categories_tests.rs +++ b/crates/ui-egui/src/file_info_categories_tests.rs @@ -439,7 +439,7 @@ fn xmp_attribute_forms_supply_camera_values_without_changing_basic_behavior() { let other = if quote == '"' { '\'' } else { '"' }; let note = format!("fixture:note={other} aux:OwnerName={quote}quoted-decoy{quote}{other}"); let packet = format!( - r#""# + r#""# ); let mut session = photocraft_engine::Session::new(); session.execute("file.new", json!({"width": 64, "height": 48})).unwrap(); @@ -469,4 +469,10 @@ fn xmp_attribute_forms_supply_camera_values_without_changing_basic_behavior() { assert!(xmp.contains("fixture:opaque=\"preserve-me\"")); assert!(xmp.contains(&format!(""))); } + // The pre-existing Marked scanner also reads PI pseudo-attributes. Camera-only correction + // must not silently change that Basic behavior while its separate scope is under review. + let marked = photocraft_engine::file_cmds::read_file_info(Some( + r#""#, + )); + assert_eq!(marked["copyrightStatus"], "publicDomain", "keep pre-PR Marked behavior"); }