From e3dded7a85c68f8445a735d70920fc00a808621b Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Tue, 25 Mar 2025 12:13:52 -0600 Subject: [PATCH] fish: Fix manpage completion generation with paths containing spaces (#6703) Manual pages with spaces in their paths can lead to argument injection. --- modules/programs/fish.nix | 2 +- tests/modules/programs/fish/default.nix | 1 + tests/modules/programs/fish/manpage.nix | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/modules/programs/fish/manpage.nix diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 73691d5fb..d4f9751d9 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -449,7 +449,7 @@ in { for src in $srcs; do if [ -d $src/share/man ]; then find -L $src/share/man -type f \ - | xargs python ${cfg.package}/share/fish/tools/create_manpage_completions.py --directory $out \ + -exec python ${cfg.package}/share/fish/tools/create_manpage_completions.py --directory $out {} + \ > /dev/null fi done diff --git a/tests/modules/programs/fish/default.nix b/tests/modules/programs/fish/default.nix index f81ff971e..f7da4d4d0 100644 --- a/tests/modules/programs/fish/default.nix +++ b/tests/modules/programs/fish/default.nix @@ -4,4 +4,5 @@ fish-functions = ./functions.nix; fish-no-functions = ./no-functions.nix; fish-plugins = ./plugins.nix; + fish-manpage = ./manpage.nix; } diff --git a/tests/modules/programs/fish/manpage.nix b/tests/modules/programs/fish/manpage.nix new file mode 100644 index 000000000..2601b69c7 --- /dev/null +++ b/tests/modules/programs/fish/manpage.nix @@ -0,0 +1,12 @@ +{ lib, pkgs, ... }: { + config = { + programs.fish = { enable = true; }; + + home.packages = [ + (pkgs.runCommand "manpage-with-space" { } '' + mkdir -p $out/share/man/man1 + echo "It works!" >"$out/share/man/man1/hello -inject.1" + '') + ]; + }; +}