From 04c3247144ca8cf8eb138d3bca0ee65da41df494 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 30 Apr 2025 22:28:50 +0100 Subject: [PATCH] docs: ensure path is escaped when copying module docs Without escaping the path here, filepaths for options named things like `*` will result in undefined behaviour. --- docs/mdbook/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index 72eedd41..c10f550a 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -216,7 +216,10 @@ let name: opts: let isBranch = if (lib.hasSuffix "index" opts.index.path) then true else opts.hasComponents; - path = if isBranch then "${opts.index.path}/index.md" else "${opts.index.path}.md"; + # Ensure `path` is escaped because we use it in a shell script + path = lib.strings.escapeShellArg ( + if isBranch then "${opts.index.path}/index.md" else "${opts.index.path}.md" + ); in (lib.optionalString isBranch "mkdir -p ${opts.index.path}\n") + (