From 8459c52a8cfb5a0f5e7a7536d1b5fea492658ec9 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 05:21:40 -0800 Subject: [PATCH] MCP: confined exports refuse native files that name a linked JavaScript file outside the read roots Under --automation-read-root, a document that links a JavaScript file outside the read roots could still be written by a confined caller to any output that carries the native document, and that document holds the stored path. SVG and SVGZ output was already refused. This change applies the same control to every output that carries the native document, and they now return the same error, "a linked JavaScript file is outside the read roots", without the path: - document.serialize, document.export, document.exportSelection and document.exportEps for vectorcraft, template, EPS, .ai and .ait files (not a legacy version 7 .ai file, a .ai file of some of the artboards, or one of the art's bounds) - PDF with Preserve Editing on, as its preset, standard and options leave it, when it holds every artboard, including document.exportPdf - document.save, file.saveAs and file.saveAsTemplate - document.exportForScreens and assets.export, checked with the artboards each file is written with - file.exportAs in the app - file.package, before the folder is made, including when a linked native document, or the native document a linked PDF, .ai or EPS file carries, links such a file Outputs that do not carry the native document, unconfined callers and linked files inside the read roots are written as before. --- crates/engine/src/cmd/fileio.rs | 1 + crates/engine/src/cmd/fileio/access.rs | 54 +++++++-- crates/engine/src/cmd/fileio/commands.rs | 8 +- crates/engine/src/cmd/fileio/export.rs | 7 +- crates/engine/src/cmd/fileio/pdf.rs | 3 +- crates/engine/src/cmd/fileio/save.rs | 13 ++- crates/engine/src/cmd/fileio/screens.rs | 31 ++++- crates/engine/src/cmd/package.rs | 29 ++++- crates/engine/src/tests/interactivity.rs | 136 ++++++++++++++++++++++ crates/engine/src/tests/package.rs | 54 +++++++++ crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/dialogs/svg_options.rs | 2 +- crates/ui-egui/src/io/export.rs | 4 +- crates/ui-egui/src/menus/ui_commands.rs | 2 +- crates/ui-egui/src/tests/automation.rs | 33 ++++++ docs/mcp.md | 16 ++- docs/target-app-parity.md | 1 + 17 files changed, 362 insertions(+), 34 deletions(-) diff --git a/crates/engine/src/cmd/fileio.rs b/crates/engine/src/cmd/fileio.rs index 84fb121d0c..278182baf3 100644 --- a/crates/engine/src/cmd/fileio.rs +++ b/crates/engine/src/cmd/fileio.rs @@ -121,6 +121,7 @@ mod commands; mod export_names; mod formats; +pub(crate) use access::check_scripts_of; #[cfg(not(target_arch = "wasm32"))] pub(crate) use access::list_dir; pub use access::{check_linked_scripts, write_file_with, write_save_file, write_save_file_with}; diff --git a/crates/engine/src/cmd/fileio/access.rs b/crates/engine/src/cmd/fileio/access.rs index 203a2262b0..457448423b 100644 --- a/crates/engine/src/cmd/fileio/access.rs +++ b/crates/engine/src/cmd/fileio/access.rs @@ -121,22 +121,54 @@ pub(crate) fn naming_in_message(msg: &str, path: &str, name: &str) -> String { out } -/// The error for an SVG of a document that links a JavaScript file outside the read roots. +/// The error for a file that would name a JavaScript file the document links outside the read roots. pub(crate) const SCRIPT_OUTSIDE: &str = "a linked JavaScript file is outside the read roots"; -/// `cmd` may write `st`'s document in format `format` (a format id): any format but SVG and SVGZ, -/// and those too unless read roots are in force and the document links a JavaScript file outside -/// them (`svg_scripts`, a relative path taken from the document's folder; a URL is not checked), -/// which the file's `