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.
This commit is contained in:
dotCooCoo
2026-11-14 05:21:40 -08:00
parent a47d7eec91
commit 8459c52a8c
17 changed files with 362 additions and 34 deletions
+1
View File
@@ -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};
+43 -11
View File
@@ -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 `<script>` element would name. The error names no file or folder.
pub fn check_linked_scripts(cmd: &str, format: &str, st: &crate::DocState) -> Result<()> {
if !matches!(format, "svg" | "svgz") || crate::file_access::current().is_none() {
/// `cmd` may write `st`'s document in format `format` (a format id) with options `p` (presets
/// written out): always, unless read roots are in force, the document links a JavaScript file
/// outside them (`svg_scripts`, a relative path taken from the document's folder; a URL is not
/// checked) and the file names it ([`names_linked_scripts`], with the artboards `p` picks counted
/// in `st`'s document): an SVG's `<script>` element, or the native document that a native file, a
/// `.ai` file, an EPS file or a PDF with Preserve Editing carries. The error names no file or folder.
pub fn check_linked_scripts(cmd: &str, format: &str, st: &crate::DocState, p: &Value) -> Result<()> {
check_scripts_of(cmd, &st.doc, st.path.as_deref(), || names_linked_scripts(cmd, format, p, st.doc.artboards.len()))
}
/// `doc`, saved at `doc_path`, may be written by `cmd` in a file that names its linked JavaScript
/// files when `names` says so: as [`check_linked_scripts`] allows it.
pub(crate) fn check_scripts_of(cmd: &str, doc: &vectorcraft_doc::Document, doc_path: Option<&str>, names: impl FnOnce() -> bool) -> Result<()> {
if crate::file_access::current().is_none() || !doc.svg_scripts.iter().any(|f| crate::cmd::links::script_hidden(f, doc_path)) || !names() {
return Ok(());
}
let doc_path = st.path.as_deref();
if st.doc.svg_scripts.iter().any(|f| crate::cmd::links::script_hidden(f, doc_path)) {
return Err(bad(cmd, SCRIPT_OUTSIDE));
Err(bad(cmd, SCRIPT_OUTSIDE))
}
/// Does a file of a document with `artboards` artboards, written in format `format` with options
/// `p`, name the JavaScript files the document links? SVG, SVGZ, native files, native templates and
/// EPS files always do. A `.ai` or `.ait` file does unless it is a legacy version 7 `.ai` file or `p`
/// picks only some of the artboards; a PDF does with Preserve Editing on (as its preset, standard and
/// options leave it) unless `p` picks only some of the artboards. Neither a `.ai` file nor a PDF
/// does when `useArtboards` is false in `p` (one page, the bounds of the art). Options the encoder
/// refuses count as naming them.
pub(crate) fn names_linked_scripts(cmd: &str, format: &str, p: &Value, artboards: usize) -> bool {
use serde::Deserialize;
let every_artboard = || {
let pick = if p.is_object() { super::ArtboardPick::deserialize(p).ok() } else { Some(super::ArtboardPick::default()) };
pick.and_then(|pick| pick.resolve(artboards).ok()).is_none_or(|v| v.is_none_or(|v| v.iter().copied().eq(0..artboards)))
};
let art_page = || super::encode::use_artboards(cmd, p).is_ok_and(|u| u == Some(false));
match format {
"svg" | "svgz" | "vectorcraft" | "template" | "eps" => true,
"ai" | "ait" => {
let legacy = super::format(format).is_some_and(|f| super::legacy_ai::wanted(cmd, f, p).unwrap_or(false));
!legacy && !(format == "ai" && art_page()) && every_artboard()
}
"pdf" => {
let editing = super::pdf::settings(cmd, p).ok().is_none_or(|s| s.preserve_editing);
editing && !art_page() && every_artboard()
}
_ => false,
}
Ok(())
}
/// `path` checked for writing against the automation roots in force.
File diff suppressed because one or more lines are too long
+4 -3
View File
@@ -53,10 +53,10 @@ pub(super) fn export_reads(f: &Format, legacy: bool, key: &str) -> bool {
pub(super) fn serialize(s: &mut Session, p: &Value) -> Result<Value> {
let f = writable("document.serialize", Some(text_param(p, "format", "document.serialize")?.unwrap_or("vectorcraft")), None)?;
check_linked_scripts("document.serialize", f.id, s.doc()?)?;
let unused = unused_option_notes("document.serialize", f, p);
let expanded = expand_presets(s, "document.serialize", p)?;
let p = with_black_output(s, &expanded);
check_linked_scripts("document.serialize", f.id, s.doc()?, &p)?;
let (doc, display_doc_title) = source(s, f, &p, "document.serialize")?;
let doc = &*doc;
let mut q = p.clone();
@@ -97,10 +97,10 @@ pub(super) fn export(s: &mut Session, p: &Value) -> Result<Value> {
super::check_not_lossy_overwrite(s.doc()?, path, p, "document.export")?;
}
let f = writable("document.export", text_param(p, "format", "document.export")?, path)?;
check_linked_scripts("document.export", f.id, s.doc()?)?;
let unused = unused_option_notes("document.export", f, p);
let expanded = expand_presets(s, "document.export", p)?;
let p = with_black_output(s, &expanded);
check_linked_scripts("document.export", f.id, s.doc()?, &p)?;
let (doc, display_doc_title) = source(s, f, &p, "document.export")?;
let doc = &*doc;
let mut q = p.clone();
@@ -367,10 +367,11 @@ pub(super) fn export_selection(s: &mut Session, p: &Value) -> Result<Value> {
super::check_not_lossy_overwrite(s.doc()?, path, p, C)?;
}
let f = writable(C, text_param(p, "format", C)?, path)?;
check_linked_scripts(C, f.id, s.doc()?)?;
let unused = unused_option_notes(C, f, p);
let expanded = expand_presets(s, C, p)?;
let p = with_black_output(s, &expanded);
// The selection is written on one artboard of its own: every artboard, whatever `p` picks.
check_linked_scripts(C, f.id, s.doc()?, &without_artboards(&p))?;
let (d, bounds) = selection(s, C, f.id == "txt")?;
// The encoder's warnings (options accepted but not applied, features approximated or left
// out), as document.export reports them.
File diff suppressed because one or more lines are too long
+10 -3
View File
@@ -880,7 +880,6 @@ pub(crate) fn job_for(s: &Session, st: &DocState, plan: SavePlan) -> Result<Save
fn job_for_stamped(s: &Session, st: &DocState, plan: SavePlan, stamped: Option<i64>) -> Result<SaveJob> {
let cmd = plan.mode.command();
super::check_linked_scripts(cmd, plan.format.id, st)?;
let mut own = doc_to_save(st, plan.format);
// The file the document is saved as (else its own) titles it if New's name is all it has.
let file = plan.path.as_deref().filter(|_| plan.retargets()).or(st.path.as_deref());
@@ -923,6 +922,14 @@ fn job_for_stamped(s: &Session, st: &DocState, plan: SavePlan, stamped: Option<i
o.insert("range".into(), json!("all"));
}
}
// A saved `.ai` or `.ait` file has the artboards as its pages, whatever `useArtboards` says.
let checked = match (&params, plan.format.id) {
(Value::Object(o), "ai" | "ait") => {
std::borrow::Cow::Owned(Value::Object(o.iter().filter(|(k, _)| *k != "useArtboards").map(|(k, v)| (k.clone(), v.clone())).collect()))
}
_ => std::borrow::Cow::Borrowed(&params),
};
super::check_linked_scripts(cmd, plan.format.id, st, &checked)?;
Ok(SaveJob { plan, doc, params, snapshot, source: st.doc.clone(), stamped, boards })
}
@@ -1298,7 +1305,7 @@ pub(super) fn specs() -> Vec<CommandSpec> {
"Save Document",
[],
None,
"{path?, format?: vectorcraft|template|pdf|svg|svgz|ai|eps (default: the path's extension, else the document's own format), options?: {…the format's options, see file.formatOptions; default: as last saved}, svg?: {…SVG options} (an SVG save keeps hidden layers, display:none, unless hiddenLayers is false), …the SVG and PDF options given flat instead (an option given flat or in svg and in options with different values is an error), compress?: bool (native, also in options: gzip; default: the useCompression preference; warnings name an option given flat or in options that the file doesn't read: a legacy .ai reads only its own options, and other .ai files don't read outlineText, hiddenObjects, transparentImages or preserveEditing), version?: 4 (3, 2 or 1: for older VectorCraft versions; 1 and 2 are never compressed), preview?: false (embed a PNG of the first artboard, at most 256 px), precision?: 0..9 (native: round path anchors and handles to this many decimal places, a smaller file; colors, transforms and type stay exact; default: exact, and a later save without it writes exactly again), separateArtboards?: false (native and .ai: also save each artboard of `range` to <name>-<artboard>.<ext> beside the file, holding that artboard and the art touching it; the result's files lists every file written), range?: \"1-3, 5\"|\"all\" (default; with separateArtboards), includeLinked?: false (keep linked files' own pixels, not just their previews; they stay linked), embedProfiles?: true (carry the ICC profiles loaded from files that the document is tagged with; opening the file installs them where missing), pdfCompatible?: true (native: also carry a PDF of every artboard; false omits it) | true for .ai (false: blank pages, only the native document; a .ai file's compress, default true, is its compression.compressText), modified?: Unix seconds|null (the File Info modified date, and created date when there is none, a save to a file stamps; default now, recorded in the journal so a replay matches; null: leave the dates)} → {path, format, bytes, warnings, files?: [path…] (the file and its artboards' files), linked?: [path…] (images an SVG links to)}. Save writes one artboard, except a .ai file and EPS (below): a .ai file is a PDF-compatible file of every artboard carrying the native document (preserveEditing always on; PDF options flat or in options), which document.open restores exactly, on the active artboard (the app's, else the one the document opened on; with editingData: false, the first); separateArtboards writes more files, one per artboard. EPS takes the options of document.exportEps: by default one file whose bounding box fits the visible art (the first artboard when no art shows), carrying the whole editable document; useArtboards: true (also when artboard, artboards or range names artboards; file.formatOptions then reports it true) makes the chosen artboard the page, drawn with its background color (without Use Artboards, only the first artboard's page when no art shows has its color), and with two or more chosen the file at the path is the central file of the visible art (again the first artboard when none shows) and each artboard is also written to <name>_<artboard>.eps beside it, holding that artboard; selectedOnly is refused; its PostScript appearance flattens transparency, as EPS requires. Without a path it writes the document's own file in its own format: a document opened from or saved as SVG/PDF/EPS saves as that again (warnings name what the format loses). No path known (never saved, converted from an older version, restored by Data Recovery, or another format) → {dataBase64, format, name, folder?, warnings} and the document stays modified. Under automation read roots, a reply leaves out the document's own file outside them when no path is given (files and linked then name the files by their file names), and a suggested folder outside them; an svg or svgz save (a document whose own format is SVG or SVGZ included) is refused, before any file is written, while the document links a JavaScript file outside them (svgInteractivity; a URL is not checked), also by file.saveAs and file.saveCopy. A key that no save format takes, beside the path or in options, and an unknown key inside a PDF option's object or svg, are refused. A terminal filesystem permission/read-only refusal returns READ_ONLY_LOCATION: followed by the reason; recovery-copy failures keep their original error. Non-UI callers never open a save panel",
"{path?, format?: vectorcraft|template|pdf|svg|svgz|ai|eps (default: the path's extension, else the document's own format), options?: {…the format's options, see file.formatOptions; default: as last saved}, svg?: {…SVG options} (an SVG save keeps hidden layers, display:none, unless hiddenLayers is false), …the SVG and PDF options given flat instead (an option given flat or in svg and in options with different values is an error), compress?: bool (native, also in options: gzip; default: the useCompression preference; warnings name an option given flat or in options that the file doesn't read: a legacy .ai reads only its own options, and other .ai files don't read outlineText, hiddenObjects, transparentImages or preserveEditing), version?: 4 (3, 2 or 1: for older VectorCraft versions; 1 and 2 are never compressed), preview?: false (embed a PNG of the first artboard, at most 256 px), precision?: 0..9 (native: round path anchors and handles to this many decimal places, a smaller file; colors, transforms and type stay exact; default: exact, and a later save without it writes exactly again), separateArtboards?: false (native and .ai: also save each artboard of `range` to <name>-<artboard>.<ext> beside the file, holding that artboard and the art touching it; the result's files lists every file written), range?: \"1-3, 5\"|\"all\" (default; with separateArtboards), includeLinked?: false (keep linked files' own pixels, not just their previews; they stay linked), embedProfiles?: true (carry the ICC profiles loaded from files that the document is tagged with; opening the file installs them where missing), pdfCompatible?: true (native: also carry a PDF of every artboard; false omits it) | true for .ai (false: blank pages, only the native document; a .ai file's compress, default true, is its compression.compressText), modified?: Unix seconds|null (the File Info modified date, and created date when there is none, a save to a file stamps; default now, recorded in the journal so a replay matches; null: leave the dates)} → {path, format, bytes, warnings, files?: [path…] (the file and its artboards' files), linked?: [path…] (images an SVG links to)}. Save writes one artboard, except a .ai file and EPS (below): a .ai file is a PDF-compatible file of every artboard carrying the native document (preserveEditing always on; PDF options flat or in options), which document.open restores exactly, on the active artboard (the app's, else the one the document opened on; with editingData: false, the first); separateArtboards writes more files, one per artboard. EPS takes the options of document.exportEps: by default one file whose bounding box fits the visible art (the first artboard when no art shows), carrying the whole editable document; useArtboards: true (also when artboard, artboards or range names artboards; file.formatOptions then reports it true) makes the chosen artboard the page, drawn with its background color (without Use Artboards, only the first artboard's page when no art shows has its color), and with two or more chosen the file at the path is the central file of the visible art (again the first artboard when none shows) and each artboard is also written to <name>_<artboard>.eps beside it, holding that artboard; selectedOnly is refused; its PostScript appearance flattens transparency, as EPS requires. Without a path it writes the document's own file in its own format: a document opened from or saved as SVG/PDF/EPS saves as that again (warnings name what the format loses). No path known (never saved, converted from an older version, restored by Data Recovery, or another format) → {dataBase64, format, name, folder?, warnings} and the document stays modified. Under automation read roots, a reply leaves out the document's own file outside them when no path is given (files and linked then name the files by their file names), and a suggested folder outside them; an svg or svgz save (a document whose own format is SVG or SVGZ included), and a save whose file carries the native document (vectorcraft, template, eps, ai but a version 7 file, pdf of every artboard with preserveEditing on and useArtboards not false), is refused, before any file is written, while the document links a JavaScript file outside them (svgInteractivity; a URL is not checked), also by file.saveAs and file.saveCopy. A key that no save format takes, beside the path or in options, and an unknown key inside a PDF option's object or svg, are refused. A terminal filesystem permission/read-only refusal returns READ_ONLY_LOCATION: followed by the reason; recovery-copy failures keep their original error. Non-UI callers never open a save panel",
has_doc,
|s, p| save(s, SaveMode::Save, p)
),
@@ -1325,7 +1332,7 @@ pub(super) fn specs() -> Vec<CommandSpec> {
"Save as Template…",
["File"],
None,
"{…as document.save} {path? (saved with the format's extension: one naming another format is replaced, and one is added to a name without it), format?: template (default) | ait (also when format is not given and the path ends in .ait), compress?, version?, preview?, precision?} a template that opens as a new untitled document: a native template (.vctemplate), or a PDF-compatible .ait written as a .ai file is (the .ai options and the PDF options, as document.save takes them for .ai; aiVersion 7 is an error); the document is unchanged → {path, format, bytes, warnings}; no path → {dataBase64, format, name: \"<name> template.<ext>\", folder: the Templates folder (preference templatesFolder), warnings}",
"{…as document.save} {path? (saved with the format's extension: one naming another format is replaced, and one is added to a name without it), format?: template (default) | ait (also when format is not given and the path ends in .ait), compress?, version?, preview?, precision?} a template that opens as a new untitled document: a native template (.vctemplate), or a PDF-compatible .ait written as a .ai file is (the .ai options and the PDF options, as document.save takes them for .ai; aiVersion 7 is an error); the document is unchanged → {path, format, bytes, warnings}; no path → {dataBase64, format, name: \"<name> template.<ext>\", folder: the Templates folder (preference templatesFolder), warnings}. Under automation read roots, it is refused, before any file is written, while the document links a JavaScript file outside them, as document.save refuses it",
has_doc,
|s, p| save(s, SaveMode::Template, p)
),
+27 -4
View File
@@ -1089,6 +1089,29 @@ pub(crate) fn with_export_preset(s: &Session, cmd: &str, settings: &mut Map<Stri
Ok(())
}
/// Does the file of `item` that row `r` writes carry the native document, and with it the
/// JavaScript files the document links ([`super::access::names_linked_scripts`])? A PDF holds the
/// artboards it is written with: those of `single` (Export PDFs As › Single file), every artboard
/// (Full Document), else the item's artboard of its document.
fn names_scripts(item: &Item, r: &Row, single: Option<&[usize]>) -> bool {
if r.format.id != "pdf" {
return super::access::names_linked_scripts(C, r.format.id, &r.options, item.doc.artboards.len());
}
let (doc, options) = match (single, &item.every_artboard) {
(Some(boards), _) => {
let mut options = r.options.clone();
options["range"] = json!(boards.iter().map(|b| (b + 1).to_string()).collect::<Vec<_>>().join(", "));
(&item.doc, options)
}
(None, Some(all)) => (all, r.options.clone()),
(None, None) => match r.options_for(item.region, item.artboard) {
Ok(options) => (&item.doc, options),
Err(_) => return true,
},
};
super::access::names_linked_scripts(C, "pdf", &options, doc.artboards.len())
}
/// Every chosen artboard (asset, layer, selected object) in every format row, one file each (a PDF
/// holds its artboard alone), or with `fullDocument` one file per row (a PDF of every artboard,
/// else the bounds of all art). Items that share a name get `-2`, `-3`… instead of overwriting, and
@@ -1105,10 +1128,6 @@ pub(crate) fn export(s: &mut Session, p: &Value, asked: &Value) -> Result<Value>
o.one_source()?;
// `<filename>`: the document's file, as Save names it, or its title before it is saved.
let st = s.doc()?;
// Before the folder is made or any row is written.
for r in &rows {
super::check_linked_scripts(C, r.format.id, st)?;
}
let naming = Naming::of(&o, st.path.as_deref().unwrap_or(&st.doc.title))?;
let selection = o.selection_mode()?;
let selected = if selection.is_some() { selected_artwork(s)? } else { vec![] };
@@ -1125,6 +1144,10 @@ pub(crate) fn export(s: &mut Session, p: &Value, asked: &Value) -> Result<Value>
};
let crop = rows.iter().any(|r| r.format.id != "pdf");
let items = items(&doc, &o, selection, &selected, &naming.filename, crop, true)?;
// Before the folder is made or any row is written, with the artboards each file holds.
let single: Option<Vec<usize>> = items.iter().map(|i| i.artboard).collect::<Option<Vec<_>>>().filter(|a| naming.single_pdf && a.len() > 1);
let st = s.doc()?;
super::check_scripts_of(C, &st.doc, st.path.as_deref(), || rows.iter().any(|r| items.iter().any(|i| names_scripts(i, r, single.as_deref()))))?;
// Appearance of Black › Printing / Exporting for RGB raster rows.
// Include Artboard Fill off: the encoders leave the background colors out.
let fill = if o.include_artboard_fill == Some(false) { json!({ "includeArtboardFill": false }) } else { json!({}) };
+28 -1
View File
@@ -24,7 +24,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Package",
[],
None,
"{folder?, name?: (default: \"<document> Folder\"), copyLinks?: true, linksFolder?: true (the linked files go in Links/, else next to the document), relink?: true (the packaged document links to the copies), copyFonts?: true (the fonts its type uses go in Fonts/; fonts whose licence doesn't allow embedding are left out), report?: true (<document> Report.txt)} copy the saved document as it is now into folder/name as <document>.vectorcraft with its linked files and fonts; the open document doesn't change → {folder, files: [paths relative to folder/name], links, fonts (counts copied), missingLinks: [file names not found], skippedFonts: [{font, reason}], warnings: [nested files copied unchanged or cycles/depth stopped]}; no folder → the same with {name: \"<name>.zip\", dataBase64} (a zip of the files in <name>/) instead of folder. The warnings and the report name a file outside the automation read roots by its file name",
"{folder?, name?: (default: \"<document> Folder\"), copyLinks?: true, linksFolder?: true (the linked files go in Links/, else next to the document), relink?: true (the packaged document links to the copies), copyFonts?: true (the fonts its type uses go in Fonts/; fonts whose licence doesn't allow embedding are left out), report?: true (<document> Report.txt)} copy the saved document as it is now into folder/name as <document>.vectorcraft with its linked files and fonts; the open document doesn't change → {folder, files: [paths relative to folder/name], links, fonts (counts copied), missingLinks: [file names not found], skippedFonts: [{font, reason}], warnings: [nested files copied unchanged or cycles/depth stopped]}; no folder → the same with {name: \"<name>.zip\", dataBase64} (a zip of the files in <name>/) instead of folder. The warnings and the report name a file outside the automation read roots by its file name. Under automation read roots, the package is refused, before any file is written, while the document, or a linked native document or a linked PDF, .ai or EPS file's native document, links a JavaScript file outside them (svgInteractivity; a URL is not checked)",
has_doc,
package
)]
@@ -113,6 +113,30 @@ thread_local! {
pub(crate) static PARTS_READ: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
}
/// The native document that the linked file `name` (`bytes`) is, or carries as the editing data of
/// a PDF, `.ai` or EPS file; `None` for other files and for data that can't be read.
fn carried_document(name: &str, bytes: &[u8]) -> Option<Document> {
if super::place::document::is_native(name, bytes) {
return vectorcraft_format::load_file(bytes).ok().map(|f| f.doc);
}
let data =
if super::place::document::is_pdf(name, bytes) { vectorcraft_pdf::editing(bytes).map(|e| e.data) } else { vectorcraft_eps::native(bytes) };
vectorcraft_format::load(&data?).ok()
}
/// Under read roots, the linked file `name` (`bytes`, found at `path`) is copied only when the
/// native document it is or carries ([`carried_document`]) links no JavaScript file outside them (a
/// relative path taken from the file's folder): the copy would name it.
fn check_carried_scripts(name: &str, bytes: &[u8], path: &str) -> Result<()> {
if crate::file_access::current().is_none() {
return Ok(());
}
match carried_document(name, bytes) {
Some(carried) => super::fileio::check_scripts_of(C, &carried, Some(path), || true),
None => Ok(()),
}
}
/// The fonts of the type on `pages` of the PDF or `.ai` file `name` (`bytes`, found at `path`);
/// none for other files.
fn page_fonts(name: &str, bytes: &[u8], path: &str, pages: &PlacedPages) -> BTreeSet<super::fonts::UsedFont> {
@@ -291,6 +315,7 @@ impl<'a> Collector<'a> {
// read from its editing data links are copied beside it.
let pages = placed.get(&file.path);
let placed_file = pages.is_some();
check_carried_scripts(&file.name, &bytes, found_path)?;
if placed_file && let Some(mut art) = super::place::document::editing_data(&file.name, &bytes) {
if depth >= vectorcraft_doc::placed_document::MAX_DEPTH {
self.warn(&mut lines, format!("{shown}: nesting limit reached; copied unchanged without collecting its own links"));
@@ -467,6 +492,8 @@ fn prepare(s: &mut Session, p: &Value) -> Result<Package> {
let given_name = text_param(p, "name", C)?;
let folder = text_param(p, "folder", C)?;
let doc_path = s.doc()?.path.clone().ok_or_else(|| bad(C, "save the document first: Package collects a saved document"))?;
// Before anything is collected or written, here where the request's read roots are in force.
super::fileio::check_linked_scripts(C, "vectorcraft", s.doc()?, &Value::Null)?;
let stem = Path::new(&doc_path).file_stem().map_or_else(|| "Untitled".into(), |s| s.to_string_lossy().into_owned());
let name = given_name.map_or_else(|| format!("{stem} Folder"), str::to_string);
if name.trim().is_empty() || name == "." || name == ".." || name.contains(['/', '\\', ':', '*', '?', '"', '<', '>', '|']) {
+136
View File
@@ -341,3 +341,139 @@ fn svg_output_keeps_linked_javascript_files_a_caller_may_read() {
let text = run(&mut s, "document.serialize", json!({"format": "svg"}))["text"].as_str().unwrap().to_string();
assert!(text.contains(&format!("<script xlink:href=\"{outside}\"/>")), "{text}");
}
/// The JavaScript files that the native document a `document.serialize` reply carries links.
fn carried_scripts(r: &Value) -> Vec<String> {
let bytes = vectorcraft_format::base64_decode(r["dataBase64"].as_str().unwrap()).unwrap();
let native = if bytes.starts_with(b"%PDF") { vectorcraft_pdf::editing(&bytes).expect("editing data").data } else { bytes };
vectorcraft_format::load(&native).unwrap().svg_scripts
}
/// A caller confined to read roots: every output that carries the native document (a native file
/// or template, a `.ai` or EPS file, a PDF with Preserve Editing, a package) of a document that
/// links a JavaScript file outside them is refused before a file or folder is written, with an
/// error that names no file or folder, and the document keeps the link.
#[test]
fn confined_native_output_refuses_a_linked_javascript_file_outside_the_read_roots() {
let away = Folder::new("native-script-away");
let home = Folder::new("native-script-home");
let script = away.file("menu.js");
let mut s = session();
let a = rect(&mut s, 10.0);
run(&mut s, "svgInteractivity.addFile", json!({"file": script}));
run(&mut s, "assets.add", json!({"ids": [a.0]}));
let own = home.file("own.vectorcraft");
run(&mut s, "file.saveAs", json!({"path": own}));
let before = std::fs::read(&own).unwrap();
rect(&mut s, 50.0);
let roots = crate::file_access::AutomationRoots::new(&[&home.0], &[&home.0]).unwrap().unwrap();
let hidden = [away.0.to_string_lossy().into_owned(), home.0.to_string_lossy().into_owned(), "menu.js".to_string()];
let refused = |s: &mut Session, cmd: &str, p: Value| {
let e = crate::file_access::confine(Some(&roots), || s.execute(cmd, &p)).expect_err(cmd);
assert!(matches!(e, EngineError::BadParams { .. }), "{cmd} {p}: {e:?}");
let e = e.to_string();
assert!(e.contains("a linked JavaScript file is outside the read roots"), "{cmd} {p}: {e}");
for h in &hidden {
assert!(!e.contains(h.as_str()), "{cmd} {p} names {h}: {e}");
}
};
let file = |name: &str| home.file(name);
let out = file("out");
refused(&mut s, "document.serialize", json!({}));
for format in ["vectorcraft", "template", "pdf", "ai", "eps"] {
refused(&mut s, "document.serialize", json!({"format": format}));
refused(&mut s, "document.export", json!({"format": format}));
refused(&mut s, "document.export", json!({"format": format, "selectedOnly": true}));
refused(&mut s, "document.exportSelection", json!({"format": format}));
}
// Every artboard picked, and Preserve Editing asked for.
refused(&mut s, "document.serialize", json!({"format": "pdf", "range": "1", "preserveEditing": true}));
refused(&mut s, "document.serialize", json!({"format": "ai", "artboards": [0], "pdfCompatible": false}));
refused(&mut s, "document.export", json!({"format": "pdf", "path": file("export.pdf")}));
refused(&mut s, "document.export", json!({"format": "ai", "path": file("export.ai")}));
refused(&mut s, "document.export", json!({"format": "eps", "path": file("export.eps")}));
refused(&mut s, "document.export", json!({"format": "vectorcraft", "path": file("export.vectorcraft")}));
refused(&mut s, "document.exportPdf", json!({}));
refused(&mut s, "document.exportPdf", json!({"path": file("direct.pdf")}));
refused(&mut s, "document.exportEps", json!({"path": file("direct.eps")}));
refused(&mut s, "document.save", json!({}));
refused(&mut s, "document.save", json!({"path": file("save.pdf")}));
refused(&mut s, "file.saveAs", json!({"path": file("save-as.ai")}));
// A saved `.ai` file has the artboards as its pages, whatever `useArtboards` says.
refused(&mut s, "file.saveAs", json!({"path": file("save-as-art.ai"), "useArtboards": false}));
refused(&mut s, "file.saveAs", json!({"path": file("save-as.eps")}));
refused(&mut s, "file.saveCopy", json!({"path": file("copy.vectorcraft")}));
refused(&mut s, "file.saveAsTemplate", json!({}));
refused(&mut s, "file.saveAsTemplate", json!({"format": "ait"}));
refused(&mut s, "document.exportForScreens", json!({"folder": out, "formats": [{"format": "png"}, {"format": "vectorcraft"}]}));
refused(&mut s, "document.exportForScreens", json!({"zip": true, "formats": [{"format": "pdf", "preserveEditing": true}]}));
refused(&mut s, "assets.export", json!({"folder": out, "formats": [{"format": "ai"}]}));
refused(&mut s, "assets.export", json!({"folder": out, "formats": [{"format": "eps"}]}));
refused(&mut s, "file.package", json!({"folder": out}));
refused(&mut s, "file.package", json!({}));
assert_eq!(std::fs::read(&own).unwrap(), before, "the document's own file is left as it was");
let written: Vec<_> = std::fs::read_dir(&home.0).unwrap().map(|e| e.unwrap().file_name()).collect();
assert_eq!(written, ["own.vectorcraft"]);
assert_eq!(s.doc().unwrap().doc.svg_scripts, [script]);
}
/// A confined caller still writes the outputs that carry no native document (a PDF without
/// Preserve Editing, a PDF or `.ai` file of the art's bounds or of some artboards, a legacy `.ai`
/// file, an image), and
/// native outputs that link only JavaScript files it may read keep them as stored. A caller without
/// roots writes a file outside them too.
#[test]
fn confined_output_without_the_document_or_with_scripts_the_caller_may_read_is_written() {
let away = Folder::new("native-script-kept-away");
let home = Folder::new("native-script-kept-home");
let outside = away.file("menu.js");
let mut s = session();
rect(&mut s, 10.0);
run(&mut s, "artboard.new", json!({"x": 200, "y": 0, "width": 100, "height": 100}));
run(&mut s, "svgInteractivity.addFile", json!({"file": outside}));
let roots = crate::file_access::AutomationRoots::new(&[&home.0], &[&home.0]).unwrap().unwrap();
let written = |s: &mut Session, cmd: &str, p: Value| {
crate::file_access::confine(Some(&roots), || s.execute(cmd, &p)).unwrap_or_else(|e| panic!("{cmd} {p}: {e}"))
};
for p in [
json!({"format": "pdf", "preserveEditing": false}),
json!({"format": "pdf", "useArtboards": false}),
json!({"format": "pdf", "range": "2"}),
json!({"format": "ai", "artboards": [1]}),
json!({"format": "ai", "useArtboards": false}),
json!({"format": "ai", "aiVersion": "7"}),
json!({"format": "png"}),
] {
written(&mut s, "document.serialize", p);
}
written(&mut s, "document.exportPdf", json!({"preserveEditing": false}));
written(&mut s, "document.exportForScreens", json!({"zip": true, "formats": [{"format": "pdf"}]}));
// A PDF of each artboard leaves the editing data out: it holds one of the two.
written(&mut s, "document.exportForScreens", json!({"zip": true, "formats": [{"format": "pdf", "preserveEditing": true}]}));
let refused = |s: &mut Session, p: Value| {
let e = crate::file_access::confine(Some(&roots), || s.execute("document.exportForScreens", &p)).expect_err("refused").to_string();
assert!(e.contains("a linked JavaScript file is outside the read roots"), "{p}: {e}");
};
// One PDF of both artboards, and Full Document's PDF of every artboard, carry it.
refused(&mut s, json!({"zip": true, "pdfs": "single", "formats": [{"format": "pdf", "preserveEditing": true}]}));
refused(&mut s, json!({"zip": true, "fullDocument": true, "formats": [{"format": "pdf", "preserveEditing": true}]}));
// Without roots, the native document keeps a file outside them.
let r = run(&mut s, "document.serialize", json!({}));
assert_eq!(carried_scripts(&r), [outside.as_str()]);
// Files the caller may read: inside the read roots, relative to the document's folder, a URL.
let inside = home.file("menu.js");
let url = "https://example.com/scripts/menu.js";
let kept = [inside.as_str(), "lib/tools.js", url];
let mut s = session();
rect(&mut s, 10.0);
for file in kept {
run(&mut s, "svgInteractivity.addFile", json!({"file": file}));
}
run(&mut s, "file.saveAs", json!({"path": home.file("doc.vectorcraft")}));
for format in ["vectorcraft", "pdf"] {
let r = written(&mut s, "document.serialize", json!({"format": format}));
assert_eq!(carried_scripts(&r), kept, "{format}");
}
written(&mut s, "document.exportPdf", json!({"path": home.file("doc.pdf")}));
written(&mut s, "file.package", json!({}));
}
+54
View File
@@ -319,6 +319,60 @@ fn a_confined_package_names_files_outside_the_read_root_by_name() {
assert!(info.to_string().contains(&dir.file("art/red.png")), "the person's: {info}");
}
/// A confined request packages no document that links, or places a native document or a PDF with
/// Preserve Editing that links, a JavaScript file outside its read roots: the package is refused
/// before anything is written, with an error that names no file or folder. A JavaScript file inside
/// them is packaged, and so is one outside them when the person packages.
#[test]
fn a_confined_package_refuses_a_linked_javascript_file_outside_the_read_root() {
let away = Folder::new("package-script-away");
let home = Folder::new("package-script-home");
let script = away.file("menu.js");
let roots = crate::file_access::AutomationRoots::new(&[&home.0], &[&home.0]).unwrap().unwrap();
let hidden = [away.0.to_string_lossy().into_owned(), home.0.to_string_lossy().into_owned(), "menu.js".to_string()];
let refused = |s: &mut Session, p: Value| {
let e = crate::file_access::confine(Some(&roots), || s.execute("file.package", &p)).expect_err("refused");
assert!(matches!(e, EngineError::BadParams { .. }), "{p}: {e:?}");
let e = e.to_string();
assert!(e.contains("a linked JavaScript file is outside the read roots"), "{p}: {e}");
for h in &hidden {
assert!(!e.contains(h.as_str()), "{p} names {h}: {e}");
}
};
let mut part = session();
run(&mut part, "shape.rectangle", json!({"x": 10, "y": 10, "width": 30, "height": 30}));
run(&mut part, "svgInteractivity.addFile", json!({"file": script}));
std::fs::create_dir_all(home.0.join("art")).unwrap();
let native = home.file("art/part.vectorcraft");
save(&mut part, &native);
let r = run(&mut part, "document.serialize", json!({"format": "pdf"}));
let pdf = home.file("art/part.pdf");
write(&pdf, &vectorcraft_format::base64_decode(r["dataBase64"].as_str().unwrap()).unwrap());
let out = home.file("out");
refused(&mut part, json!({"folder": out}));
refused(&mut part, json!({}));
for placed in [&native, &pdf] {
let mut s = session();
let r = run(&mut s, "file.place", json!({"path": placed, "link": true}));
assert_eq!(r["linked"], true, "{r}");
save(&mut s, &home.file("poster.vectorcraft"));
refused(&mut s, json!({"folder": out}));
refused(&mut s, json!({}));
assert!(!std::path::Path::new(&out).exists(), "{placed}");
// The person's package copies it.
assert_eq!(run(&mut s, "file.package", json!({}))["links"], 1, "{placed}");
}
// A JavaScript file inside the read roots.
run(&mut part, "svgInteractivity.removeFile", json!({"file": script}));
run(&mut part, "svgInteractivity.addFile", json!({"file": home.file("menu.js")}));
save(&mut part, &native);
let mut s = session();
run(&mut s, "file.place", json!({"path": native, "link": true}));
save(&mut s, &home.file("poster.vectorcraft"));
let r = crate::file_access::confine(Some(&roots), || s.execute("file.package", &json!({"folder": out}))).unwrap();
assert_eq!(r["links"], 1, "{r}");
}
/// A missing link stored as a path relative to the document names a file inside a confined
/// request's read root: the package report and Document Info give its stored path.
#[test]
+1 -1
View File
@@ -1330,7 +1330,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"file.exportAs",
"Export As…",
"",
"{format?, useArtboards?, range?} opens Export As (then the format's options); with {path, …document.export options} writes the file(s) → {path, warnings, files?}; exportSelection: true writes the selection alone, cropped to it, as document.exportSelection writes it (artboard options are not used); under automation read roots, an SVG or SVGZ is refused while the document links a JavaScript file outside them, as document.export refuses it",
"{format?, useArtboards?, range?} opens Export As (then the format's options); with {path, …document.export options} writes the file(s) → {path, warnings, files?}; exportSelection: true writes the selection alone, cropped to it, as document.exportSelection writes it (artboard options are not used); under automation read roots, an SVG or SVGZ, or a file that carries the native document, is refused while the document links a JavaScript file outside them, as document.export refuses it",
),
(
"ui.fileInfoDialog",
+1 -1
View File
@@ -291,7 +291,7 @@ fn code_view(app: &VectorcraftApp, ui: &mut egui::Ui, d: &Dialog) {
Some((_, c)) => c,
None => {
const MAX: usize = 200_000;
let encoded = vectorcraft_engine::cmd::fileio::check_linked_scripts("document.export", "svg", st)
let encoded = vectorcraft_engine::cmd::fileio::check_linked_scripts("document.export", "svg", st, &json!({}))
.and_then(|()| vectorcraft_engine::cmd::fileio::encode_all(&st.doc, "svg", &json!({ "svg": opts })));
let mut text = match encoded {
// Shown as text whatever the file's encoding.
+3 -1
View File
@@ -73,7 +73,9 @@ pub fn export(app: &mut VectorcraftApp, format: Option<&str>, path: Option<Strin
// A `.ai` file names the view's active artboard.
remember_active_artboard(app);
let st = app.session.active().ok_or("no document")?;
fileio::check_linked_scripts("file.exportAs", f.id, st).map_err(|e| e.to_string())?;
// With a saved PDF preset written out, as the encoder reads it.
let checked = fileio::pdf::expand_preset(&app.session, "file.exportAs", params).unwrap_or(std::borrow::Cow::Borrowed(params));
fileio::check_linked_scripts("file.exportAs", f.id, st, &checked).map_err(|e| e.to_string())?;
let doc = if selection {
std::sync::Arc::new(fileio::selection_doc(st, "document.exportSelection", f.id == "txt").map_err(|e| e.to_string())?.0)
} else {
+1 -1
View File
@@ -1331,7 +1331,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"file.exportAs",
"Export As…",
"",
"{format?, useArtboards?, range?} opens Export As (then the format's options); with {path, …document.export options} writes the file(s) → {path, warnings, files?}; exportSelection: true writes the selection alone, cropped to it, as document.exportSelection writes it (artboard options are not used); under automation read roots, an SVG or SVGZ is refused while the document links a JavaScript file outside them, as document.export refuses it",
"{format?, useArtboards?, range?} opens Export As (then the format's options); with {path, …document.export options} writes the file(s) → {path, warnings, files?}; exportSelection: true writes the selection alone, cropped to it, as document.exportSelection writes it (artboard options are not used); under automation read roots, an SVG or SVGZ, or a file that carries the native document, is refused while the document links a JavaScript file outside them, as document.export refuses it",
),
(
"ui.fileInfoDialog",
+33
View File
@@ -272,6 +272,39 @@ fn control_svg_export_refuses_a_linked_javascript_file_outside_the_read_root() {
let _ = std::fs::remove_dir_all(base);
}
/// `app.export`, and `file.exportAs` run as a command, write no file that carries the native
/// document (a PDF with Preserve Editing, a native file, a `.ai` or EPS file) of a document that
/// links a JavaScript file outside the read root, and the error names no file or folder; a PDF
/// without Preserve Editing is written, and the person at the keyboard exports the native file.
#[test]
fn control_native_export_refuses_a_linked_javascript_file_outside_the_read_root() {
let (mut app, tx, base) = confined("native-script");
app.run("file.new", json!({"width": 100, "height": 50})).unwrap();
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap();
let script = s(base.join("outside/menu.js"));
app.run("svgInteractivity.addFile", json!({"file": script})).unwrap();
let out = |name: &str| s(base.join("out").join(name));
for (method, params) in [
("app.export", json!({"path": out("a.pdf"), "wait": true})),
("app.export", json!({"path": out("a.ai"), "wait": true})),
("app.export", json!({"format": "eps"})),
("engine.execute", json!({"command": "file.exportAs", "params": {"path": out("a.vectorcraft"), "format": "vectorcraft"}})),
] {
let r = request(&mut app, &tx, method, params.clone());
let e = r["error"].as_str().unwrap_or_default();
assert!(e.contains("a linked JavaScript file is outside the read roots"), "{method} {params}: {r}");
assert!(!e.contains("menu.js") && !e.contains(&s(base.clone())), "{method} {params}: {r}");
}
assert_eq!(std::fs::read_dir(base.join("out")).unwrap().count(), 0, "nothing written");
let r = request(&mut app, &tx, "app.export", json!({"path": out("b.pdf"), "preserveEditing": false, "wait": true}));
assert_eq!(r["ok"], true, "{r}");
// The person at the keyboard isn't confined.
app.run("file.exportAs", json!({"path": out("a.vectorcraft"), "format": "vectorcraft"})).unwrap();
let native = vectorcraft_format::load(&std::fs::read(out("a.vectorcraft")).unwrap()).unwrap();
assert_eq!(native.svg_scripts, [script]);
let _ = std::fs::remove_dir_all(base);
}
/// `app.export` with a path writes the file when given an option only another format reads, and
/// its warnings name that option, as `document.export`'s do without a path. `file.exportAs` run
/// as a command does the same; an export that automation did not ask for gets no such note.
+13 -3
View File
@@ -242,7 +242,13 @@ the suite) keep the agent to the folders you give it:
`export`), `document.exportSelection`, `document.exportForScreens` and `assets.export` (before the folder is
made or any row is written), `document.save`, `file.save`, `file.saveAs` and `file.saveCopy` (also a save
without a path of a document whose own format is SVG or SVGZ), `file.exportAs`, and the SVG Options dialog's
Show Code. A file given as another URL (`https://…`) is not checked. The document keeps the link, and the
Show Code. The same error refuses, before any file is written, every output that carries the native document,
which holds the link: a native file or template, an EPS file, a `.ai` or `.ait` file of every artboard (not a
legacy version 7 `.ai` file; a save of a `.ai` file always has every artboard), a PDF of every artboard with
Preserve Editing on (also from `document.exportPdf`), and `file.package` (also when a linked native document,
or the native document a linked PDF, `.ai` or EPS file carries, links such a file). A PDF or `.ai` file of
some of the artboards or of the art's bounds (`useArtboards: false`), a PDF without Preserve Editing, and an
image are written as before. A file given as another URL (`https://…`) is not checked. The document keeps the link, and the
person at the keyboard exports it as stored.
- `plugin.list`, `plugin.safeMode`, `file.recovery.*` and `ui_inspect`'s `scriptReport` leave out the paths
outside the read roots, also those the person or an earlier request put there. In `plugin.list`, the plug-in
@@ -1282,7 +1288,9 @@ Preserve Editing (`preserveEditing`, on in the `VectorCraft Default` preset) emb
an embedded file (`vectorcraft-editing.vectorcraft`; files named `drawcraft-editing.drawcraft` are read too) with a
hash of the pages it was written with. `open_file` / `document.open` of such a PDF, `.ai` or `.ait` (no `pages` picked) restores the
document exactly (`restored: true`); when another app changed the pages, or the data can't be read, the artwork is
imported instead and the first warning says why. Choosing a standard turns it off (PDF/A refuses it). Save to a `.ai`
imported instead and the first warning says why. Choosing a standard turns it off (PDF/A refuses it). Under automation
read roots, a PDF that carries the native document is refused while the document links a JavaScript file outside them
(see [Confining file access](#confining-file-access)). Save to a `.ai`
path (`document.save {path: "art.ai"}` or `{format: "ai"}`) writes a PDF-compatible file that always carries the
document, takes the PDF options and keeps its path when reopened, so Save writes `.ai` again; a `.ait` opens untitled.
The restored document opens on the artboard its editing copy names as active. A file saved with `editingData: false` has
@@ -7362,7 +7370,9 @@ type uses in `Fonts/` (fonts whose licence doesn't allow embedding are listed in
the copies (each file copied once); one that can't be read is copied as it is, and a cycle of placed documents or one
past the nesting limit stops there, each with a line in `warnings` and the report. A `folder/name` where a packaged file
would replace the document or one of its linked files (the document's own folder, say) is an error, and nothing is
written. Every option defaults to true. An option that is not true or false, or a `folder` or `name` that is not a
written. Under automation read roots, the package is refused, and nothing is written, while the document, a linked
native document or the native document a linked PDF, `.ai` or EPS file carries links a JavaScript file outside them
(see [Confining file access](#confining-file-access)). Every option defaults to true. An option that is not true or false, or a `folder` or `name` that is not a
string, is an error naming the key, and nothing is written; null is the same as leaving the key out. Without `folder` (the web, or an agent that wants the bytes) the
result carries the same files as a zip (`{name: "<name>.zip", dataBase64}`, entries under `<name>/`).
+1
View File
@@ -831,6 +831,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- Link replies under `--automation-read-root`: `links.list`, `links.check`, `links.info` and `document.open`'s link rows leave out the path, found path and folder of a linked file outside the read roots, and the stored size and date of it in `links.info`; each row keeps its id, file name and status, and the document's links are not changed. `crates/engine/src/tests/linkspanel.rs` (`link_paths_outside_the_read_roots_are_left_out`), `crates/engine/src/tests/placed_document.rs` (`link_info_leaves_out_a_placed_documents_path_outside_the_read_roots`).
- Document replies under `--automation-read-root`: `document.inspect` gives `path` as null for a document file outside the read roots, and `document.json` names a linked image or placed file outside them by its file name alone, without its relative path, size or date, brush art included, leaves out a relative path that leads outside them and a stored brush entry that does not read as a brush, names a data set's image value outside them by its file name, and leaves an Export for Screens folder outside them out of `export_settings`; the document is not changed. `crates/engine/src/tests/placed_document.rs` (`document_replies_leave_out_paths_outside_the_read_roots`, `document_json_checks_brush_art_and_relative_paths_against_the_read_roots`).
- SVG output under `--automation-read-root`: `document.serialize`, `document.export`, `document.exportSelection`, `document.exportForScreens`, `assets.export`, the SVG and SVGZ saves, `file.exportAs` and the SVG Options dialog's Show Code refuse an SVG or SVGZ of a document that links a JavaScript file outside the read roots, before any file or folder is written, with an error that names no file or folder; a URL, a file inside the roots and a relative path that leads inside them are written as stored, and the person at the keyboard exports every link as stored. `crates/engine/src/tests/interactivity.rs` (`confined_svg_output_refuses_a_linked_javascript_file_outside_the_read_roots`, `svg_output_keeps_linked_javascript_files_a_caller_may_read`), `crates/ui-egui/src/tests/automation.rs` (`control_svg_export_refuses_a_linked_javascript_file_outside_the_read_root`), `crates/ui-egui/src/dialogs/svg_options.rs` (`show_code_leaves_out_a_linked_javascript_file_outside_the_read_roots`).
- Native document output under `--automation-read-root`: the same commands, `document.exportPdf` and `file.package` refuse a native file or template, an EPS file, a `.ai` or `.ait` file of every artboard (not a legacy version 7 file), a PDF of every artboard with Preserve Editing on, and a package, of a document that links a JavaScript file outside the read roots, before any file or folder is written, with the same error; a package is refused too when a linked native document, or the native document a linked PDF, `.ai` or EPS file carries, links one. A PDF or `.ai` file of some artboards or of the art's bounds, a PDF without Preserve Editing and an image are written, and linked files the caller may read are kept as stored. `crates/engine/src/tests/interactivity.rs` (`confined_native_output_refuses_a_linked_javascript_file_outside_the_read_roots`, `confined_output_without_the_document_or_with_scripts_the_caller_may_read_is_written`), `crates/engine/src/tests/package.rs` (`a_confined_package_refuses_a_linked_javascript_file_outside_the_read_root`), `crates/ui-egui/src/tests/automation.rs` (`control_native_export_refuses_a_linked_javascript_file_outside_the_read_root`).
- Linked-file and font-file searches under `--automation-read-root`: `links.findFiles` and `text.findFontFiles` replies, also later polls and stops of a search another client started, leave out the files found, a link's saved path and the folder searched outside the caller's read roots, and a failed search gives its reason without the path; `image.info` gives `link: null` for a linked file outside them; `text.addFontFiles` gives `folder: null` and the copies' file names when the Fonts folder is outside them. `crates/engine/src/tests/linkfiles.rs`, `crates/engine/src/tests/fontfiles.rs`, `crates/engine/tests/font_folder.rs`.
- Swatch, brush, symbol and graphic style library lists under `--automation-read-root`: every library stays listed, the paths of library files and the user library folder outside the read roots are `null`, a library loaded from outside them is listed and found as `loaded/<file name>` and keeps that id for the session unless a library loaded later without a file shows that id itself, which moves it to the next free `loaded/<file name> (N)`, and the app's own list is not changed. `crates/engine/src/tests/library_roots.rs`.
- Preferences commands under `--automation-read-root`: `prefs.get`, `prefs.list`, `prefs.set` and `prefs.reset` show folder preferences outside the read roots as `null` and leave out an export preset's folder outside them, and the preferences are not changed. `crates/engine/src/tests/prefs_roots.rs`.