From df9483b8392a6dc0be03dc5fe671df5daeba669b Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 18 Nov 2026 09:15:25 +0700 Subject: [PATCH] Fix #7242: confined package report test uses native path components The unconfined report path for an existing link is built from native path components so Windows separators match the package report. JSON assertions use the path encoded the same way Value::to_string does, and the unconfined Document Info check reads the report text field. Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com> --- crates/engine/src/tests/package.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/tests/package.rs b/crates/engine/src/tests/package.rs index 13464b24d7..7a064a1960 100644 --- a/crates/engine/src/tests/package.rs +++ b/crates/engine/src/tests/package.rs @@ -326,9 +326,11 @@ fn a_confined_package_names_files_outside_the_read_root_by_name() { let zip = unzip(&vectorcraft_format::base64_decode(r["dataBase64"].as_str().unwrap()).unwrap()); String::from_utf8(zip["poster Folder/poster Report.txt"].clone()).unwrap() }; + // Reopened existing links use native separators; missing links keep their stored path. + let red = dir.0.join("art").join("red.png").to_string_lossy().into_owned(); let person = report(&run(&mut s, "file.package", json!({}))); assert!(person.contains(&format!("From: {}\n", dir.file("poster.vectorcraft"))), "{person}"); - assert!(person.contains(&format!("{} → Links/red.png", dir.file("art/red.png"))), "{person}"); + assert!(person.contains(&format!("{red} → Links/red.png")), "{person}"); assert!(person.contains(&format!("blue.png: not found ({})", dir.file("art/blue.png"))), "{person}"); let in_root = dir.0.join("in"); @@ -339,16 +341,19 @@ fn a_confined_package_names_files_outside_the_read_root_by_name() { assert!(text.contains("\nred.png → Links/red.png\n") && text.contains("\nblue.png: not found (blue.png), not copied\n"), "{text}"); let base = dir.0.to_string_lossy().into_owned(); assert!(!text.contains(&base), "{text}"); + // Compare serialized JSON with the path encoded the same way, without its outer quotes. + let json_base = serde_json::to_string(&base).unwrap(); + let json_base = &json_base[1..json_base.len() - 1]; for key in ["missingLinks", "warnings", "files"] { - assert!(!client[key].to_string().contains(&base), "{key}: {client}"); + assert!(!client[key].to_string().contains(json_base), "{key}: {client}"); } // Document Info, whose report the package holds, gives no link either. for p in [json!({}), json!({"format": "text"})] { let info = crate::file_access::confine(roots.as_ref(), || run(&mut s, "document.info", p.clone())); - assert!(!info.to_string().contains(&base), "{p}: {info}"); + assert!(!info.to_string().contains(json_base), "{p}: {info}"); } let info = run(&mut s, "document.info", json!({"format": "text"})); - assert!(info.to_string().contains(&dir.file("art/red.png")), "the person's: {info}"); + assert!(info["text"].as_str().unwrap().contains(&red), "the person's: {info}"); } /// A confined request packages no document that links, or places a native document or a PDF with