From 1fd0ec7a61370f762b2d4dde2d30b88fe5e91b34 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 1 Nov 2026 02:00:10 -0600 Subject: [PATCH] Save for Web: refuse slice numbers with a whole-image path and a null `slices` (CodeRabbit review on crates/engine/src/cmd/web_cmds/save_web.rs:211) Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/web_cmds/save_web.rs | 2 +- crates/engine/src/cmd/web_cmds/tests.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/web_cmds/save_web.rs b/crates/engine/src/cmd/web_cmds/save_web.rs index db35af9c21..af655df8d7 100644 --- a/crates/engine/src/cmd/web_cmds/save_web.rs +++ b/crates/engine/src/cmd/web_cmds/save_web.rs @@ -208,7 +208,7 @@ fn slice_pick(p: &Value, cmd: &str, doc: &photocraft_doc::Document) -> Result 1 { + if given("path") && !given("dir") && matches!(p.get("slices"), None | Some(Value::Null)) && count > 1 { return Err(bad(cmd, "`path` writes the whole image as one file: to export the slices in `numbers`, use `dir`")); } // `folder` alone (#5305) is the whole image too, under the document's name. diff --git a/crates/engine/src/cmd/web_cmds/tests.rs b/crates/engine/src/cmd/web_cmds/tests.rs index 2a341c5e69..82c2a6c5a9 100644 --- a/crates/engine/src/cmd/web_cmds/tests.rs +++ b/crates/engine/src/cmd/web_cmds/tests.rs @@ -1560,6 +1560,8 @@ fn a_whole_image_path_with_slice_numbers_is_refused() { assert_refused(&mut s, &dir, json!({"format": "png24", "path": path, "dir": "", "numbers": [left, right]}), "use `dir`"); // `folder` alone is the whole image under the document's name (#5305): refused the same way. assert_refused(&mut s, &dir, json!({"format": "png24", "folder": dir, "numbers": [right]}), "use `dir`"); + // An explicit null `slices` is the default mode, as if absent. + assert_refused(&mut s, &dir, json!({"format": "png24", "path": path, "slices": null, "numbers": [right]}), "use `dir`"); // Valid calls still work: `path` alone is the whole image; with `slices`, the chosen slices // go next to it; `dir` with `numbers` writes those slices. let r = s.execute("file.export.saveForWebLegacy", json!({"format": "png24", "path": path})).unwrap();