Scripting: export commands a script runs directly respect Allow Scripts to Write Files (#2921)

* Scripting: export commands a script runs directly respect Allow Scripts to Write Files

CompItem.saveFrameToPng and exportAsMotionGraphicsTemplate checked the
file-write preference only in their JavaScript wrappers. A script could call
comp.saveFrameAs or essential.exportTemplate itself (app.run, __exec) and the
native handlers wrote the file with the preference off.

Session::refuse_export and write_output_with now refuse when the running
command was issued by a script and the preference is off, so every command
that writes a path it is given is gated the same way. The wrappers check the
gate with a new side-effect-free __file("checkWrite") instead of writing an
empty file at the destination.

* address review: clear stale export test dir before use

* test: allow script writes in script_imports_footage_and_saves
This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-11 08:24:28 -05:00
1 parent be5c98506f
commit 33a15e1d86
5 files changed
+72 -3

No files matched your search

+3 -3
View File
@@ -1658,7 +1658,7 @@ CompItem.prototype.constructor = CompItem;
P.saveFrameToPng = function (time, file) {
var f = __str(file);
if (!f) throw __err("saveFrameToPng: missing file");
__file("write", f, "");
__file("checkWrite", f);
__call("comp.saveFrameAs", { comp: this.__id, path: f, time: __num(time, "time") });
};
P.openInEssentialGraphics = function () { __call("comp.openInEssentialGraphics", { comp: this.__id }); };
@@ -1668,8 +1668,8 @@ CompItem.prototype.constructor = CompItem;
if (!/\.[A-Za-z0-9]+$/.test(f)) f += ".ectemplate";
if (!overwrite && JSON.parse(__file("exists", f)) === true) return false;
if (this.__controllers().length === 0) return false;
// The file gate applies to templates too.
__file("write", f, "");
// The file gate applies to templates too (checked without touching the file).
__file("checkWrite", f);
__call("essential.exportTemplate", { comp: this.__id, path: f });
return true;
};