Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Workers: a run whose id starts with "-" is no longer refused for its save name

Adarsh9047db843476
diff --git a/bin/lib/worker/rules.mjs b/bin/lib/worker/rules.mjs
index f7d97ace..73baf5dc 100644
--- a/bin/lib/worker/rules.mjs
+++ b/bin/lib/worker/rules.mjs
@@ -39,8 +39,12 @@ export const TEXT_NAME = /^(text|texts|prompt|prompts|positive|negative|caption|
/** File names that hold weights (or pickled code). */
export const MODEL_EXT = /\.(safetensors|gguf|ckpt|pt|pt2|pth|bin|sft|onnx|pkl|pickle)$/i;
-/** A save name the studio makes: name parts of letters, digits, "_", "-" and ".", joined by "/"; no "..". */
-const OUTPUT_NAME = /^(?!.*\.\.)[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}(\/[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}){0,7}$/;
+/**
+ * A save name the studio makes: name parts of letters, digits, "_", "-" and ".", joined by "/"; no "..". The first part
+ * starts with a letter, a digit or "_"; a later one may also start with "-" (the studio names a run's files after its id,
+ * "fuobe/<id>", and an id may start with "-").
+ */
+const OUTPUT_NAME = /^(?!.*\.\.)[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}(\/[A-Za-z0-9_-][A-Za-z0-9_.-]{0,127}){0,7}$/;
const DEVICE = /^(con|prn|aux|nul|com[0-9¹²³]|lpt[0-9¹²³]|conin\$|conout\$)(\..*)?$/i;
diff --git a/tests/worker-input-rules.test.ts b/tests/worker-input-rules.test.ts
index 27015ff1..c012a409 100644
--- a/tests/worker-input-rules.test.ts
+++ b/tests/worker-input-rules.test.ts
@@ -120,10 +120,21 @@ describe("the worker's input rules", () => {
// The multi-talk node's output path, and a save name.
const talk = { class_type: "WanVideoImageToVideoMultiTalk", inputs: { width: 832, height: 480, frame_window_size: 81, motion_frame: 9, force_offload: false, colormatch: "disabled", tiled_vae: false, mode: "infinitetalk", output_path: "C:x" } };
expect(check({ "1": talk })).toBe("unsafe-path");
- for (const p of ["../x", "/x", "C:/x", "x/../../y", "fuobe/%date%"]) expect(check({ "1": { class_type: "SaveImage", inputs: { images: ["2", 0], filename_prefix: p } } }), p).toBe("unsafe-path");
+ for (const p of ["../x", "/x", "C:/x", "x/../../y", "fuobe/%date%", "-x/y", "fuobe/.x", "fuobe/-/../x"]) expect(check({ "1": { class_type: "SaveImage", inputs: { images: ["2", 0], filename_prefix: p } } }), p).toBe("unsafe-path");
expect(check({ "1": { class_type: "SaveImage", inputs: { images: ["2", 0], filename_prefix: "fuobe/gen-1_a" } } })).toBeNull();
});
+ it("takes the save name of every run id, one that starts with \"-\" too", async () => {
+ const { nanoid } = await import("nanoid");
+ const save = (id: string) => check({ "1": { class_type: "SaveImage", inputs: { images: ["2", 0], filename_prefix: `fuobe/${id}` } } });
+ expect(save("-r90nWOv8wC4")).toBeNull();
+ expect(save("_r90nWOv8wC4")).toBeNull();
+ for (let i = 0; i < 500; i++) {
+ const id = nanoid(12);
+ expect(save(id), id).toBeNull();
+ }
+ });
+
it("a format string stays the catalog's (no walk into the environment)", () => {
const walk = { class_type: "StringFormat", inputs: { "values.a": ["9", 0], f_string: "{a.__init__.__globals__[os].environ}" } };
expect(check({ "9": { class_type: "VAELoader", inputs: { vae_name: "ae.safetensors" } }, "1": walk })).toBe("unsafe-path");