mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 13:02:50 -05:00
Scripts: PlacedItem.file checks the script's own read scope, not open documents
Reading file of a placed image linked to a file outside the script's read scope throws Script file access denied even when that file is also open as a document, whose file the script's commands may read.
This commit is contained in:
1 parent
dc7d5ccfd7
commit
bbc85020e0
2 files changed
+17
-3
No files matched your search
@@ -289,10 +289,10 @@ fn doc_raster(h: &Host, a: &[Data]) -> Answer {
|
||||
|
||||
// ---- files ----
|
||||
|
||||
/// Whether the script's commands may read `path` now ([`crate::file_access::ScriptGate`]).
|
||||
/// Whether the script may read `path` now by its own read scope and the read roots
|
||||
/// ([`crate::file_access::ScriptGate`]), without the open documents' files a command may also read.
|
||||
fn may_read(h: &Host, path: &str) -> bool {
|
||||
let documents = h.session.borrow().documents().iter().filter_map(|d| d.path.clone()).collect();
|
||||
let gate = h.disk.borrow().gate(documents);
|
||||
let gate = h.disk.borrow().gate(Vec::new());
|
||||
crate::file_access::with_script_gate(gate, || crate::file_access::check_read(path)).is_ok()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user