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.
This commit is contained in:
Matt Sturgeon 2025-04-30 22:28:50 +01:00
parent 6297f4c01a
commit 04c3247144
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -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")
+ (