Scripts: refuse unsafe close saves and refused multi-file writes up front

- A save of several files whose file access refuses one of them returns
  the refusal before any file goes to the writer, so a writer that does
  not check the file access writes nothing.
- close(SaveOptions.SAVECHANGES) throws before writing, and leaves the
  document open, when the document's last save named some of its
  artboards, since saving with those options again could leave changes
  out of the file.
- The script check no longer treats an object literal's saveAs or
  exportFile as the script's own when a function body assigns the
  variable without declaring it, or when the script assigns it as a
  property of this (the global object in global code and in a function
  called without a receiver).
- The close-with-SAVECHANGES format test reads the saved PDF and checks
  that it holds the change made after the first save.
- docs/mcp.md limits the "none of them is written" sentence for SVG
  linked images to refusals found before the first write, and documents
  the new close refusal.
This commit is contained in:
dotCooCoo committed 2026-11-28 03:15:22 -08:00
1 parent 887c67a8f1
commit 39c5e98a3e
7 files changed
+168 -14

No files matched your search

+4 -2
View File
@@ -2935,7 +2935,8 @@ other files through `$`:
format's extension unless the name already ends with it (`.jpg` or `.jpeg`, `.tif` or `.tiff`, `.svgz` with
`compressed`), and writes one file: the active artboard with `artBoardClipping`, otherwise the bounds of the
visible art. An SVG with `embedRasterImages` false also writes the document's embedded images beside it, and
when one of those files may not be written, none of them is. A listed option that is not mapped is accepted at its help page's default, and any other value throws
when the script's folders refuse one of those files, none of them is written; a write that fails once the
first file is in place leaves the files written before it. A listed option that is not mapped is accepted at its help page's default, and any other value throws
an error that says it is not available yet, as do `ExportType.FLASH` and `ExportType.AutoCAD`. A property the help
pages do not list throws an error that names it (`PDFFileOptions` also accepts its read-only `typename` and
`parent`), and an `undefined` one is left out. With `pDFPreset` named, a `PDFSaveOptions` option still at a new object's default
@@ -2956,7 +2957,8 @@ other files through `$`:
undo step. With unsaved changes, `close` closes without them with `SaveOptions.DONOTSAVECHANGES`;
`SaveOptions.SAVECHANGES` first saves them to the document's file with `file.saveAs`, in the format the document
was last saved in and after the same write-access check of the path as `saveAs`, and throws an error
and leaves the document open when the document has no file (a converted or recovered document included); and
and leaves the document open when the document has no file (a converted or recovered document included) or when
its last save named some of its artboards, without writing anything; and
`SaveOptions.PROMPTTOSAVECHANGES`, the default, throws an error and leaves the document open, since a script cannot
show the prompt. A bad value throws an error before anything is written.
- `PageItem.tags` and `Document.tags` are `Tags` collections (https://ai-scripting.docsforadobe.dev/jsobjref/Tags/)