automation: save_bytes never reads linked files (#11233)

This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-11 16:23:30 -05:00
1 parent 5a935b2830
commit bf162c2215
3 files changed
+33 -1

No files matched your search

+3 -1
View File
@@ -203,7 +203,9 @@ pub fn save_bytes_with_renderer(
}
return Ok((bytes, warnings));
}
let result = photocraft_io::export_with_renderer(doc, &ext, opts, &photocraft_raster::Interrupt::NONE, renderer)?;
// No ambient authority: a linked path inside the document must not be read and embedded.
let opts = ExportOptions { read_linked_files: false, ..opts.clone() };
let result = photocraft_io::export_with_renderer(doc, &ext, &opts, &photocraft_raster::Interrupt::NONE, renderer)?;
Ok((result.bytes, result.warnings))
}
@@ -0,0 +1,29 @@
//! `files::save_bytes` is the capability-scoped encoder: a linked path inside the document must
//! not be read through ambient filesystem authority and embedded in the returned bytes.
use photocraft_automation::files;
use photocraft_doc::{Document, Layer, LayerContent, SmartContentsId, SmartObject, SmartSource};
#[test]
fn a_linked_smart_object_is_not_read_into_the_bytes() {
let mut doc = Document::new("linked", photocraft_doc::Size::new(8, 6), photocraft_doc::ColorMode::Rgb, photocraft_doc::SampleType::U8);
let linked = std::env::current_exe().unwrap();
let smart = SmartObject {
contents_id: SmartContentsId::fresh(),
source: SmartSource::Linked { path: linked.to_string_lossy().into_owned() },
transform: photocraft_geom::Affine::IDENTITY,
smart_filters: vec![],
cache: Some(photocraft_raster::Surface::new(doc.pixel_format())),
psd_raw: None,
filters_enabled: true,
filter_mask: None,
warp: None,
stack_mode: None,
perspective: None,
vector_preview: None,
};
doc.layers.push(Layer::new("Linked", LayerContent::Smart(smart)));
let (bytes, warnings) = files::save_bytes(&doc, "out.psd", None, &Default::default()).unwrap();
assert!(warnings.iter().any(|w| w.contains("not read for this export")), "{warnings:?}");
assert!(bytes.len() < 1 << 20, "the test executable was not embedded");
}
+1
View File
@@ -9,6 +9,7 @@ mod gpu_backend;
mod inactive_save;
mod krita;
mod layered_save_dirty;
mod linked_save_bytes;
mod mcp;
mod mcp_wire;
mod missing_font_warnings;