fix(engine): scripts load effect plug-ins only with Allow Scripts to Write Files on

This commit is contained in:
Dylan M. Taylor
2026-11-03 15:28:34 +00:00
parent 7870b5916a
commit ef892f747f
2 changed files with 20 additions and 0 deletions
+8
View File
@@ -35,6 +35,14 @@ fn plugins_list(s: &mut Session, _: &Value) -> Result<Value> {
/// folder) through the host's loader ([`Session::plugin_loader`]).
fn plugins_load(s: &mut Session, p: &Value) -> Result<Value> {
let c = "effect.plugins.load";
// A plug-in is code, and a file that fails to load comes back in the error: a script may
// load one only with the access it would need to read and write files anywhere.
if s.running_for_script() && !s.prefs.scripting.allow_scripts_write_files {
return Err(bad(
c,
"scripts can't load effect plug-ins unless Settings ▸ Scripting & Expressions ▸ Allow Scripts to Write Files and Access Network is on",
));
}
let loader = s.plugin_loader.ok_or_else(|| EngineError::Other("WebAssembly effect plug-ins are not available in this build".into()))?;
let files: Vec<String> = match (str_p(p, "path"), str_p(p, "folder")) {
(Some(path), _) => vec![path.to_string()],
+12
View File
@@ -651,6 +651,18 @@ fn context_shortcuts_on_the_same_keys_conflict() {
assert!(t.conflicts(b, "F9").iter().any(|c| c.key == "test.paint" && !c.overrides));
}
/// A script loads effect plug-ins only with Allow Scripts to Write Files on.
#[test]
fn scripts_load_effect_plugins_only_with_file_access() {
let mut s = Session::default();
let p = json!({"path": "/etc/hostname"});
let e = s.execute_for_script("effect.plugins.load", p.clone()).unwrap_err().to_string();
assert!(e.contains("Allow Scripts to Write Files"), "{e}");
s.prefs.scripting.allow_scripts_write_files = true;
let e = s.execute_for_script("effect.plugins.load", p).unwrap_err().to_string();
assert!(!e.contains("Allow Scripts to Write Files"), "{e}");
}
// ---------------------------------------------------------------- auto-save / recovery
/// The names in `d`, sorted.