From 3e8b22051393f450f390d661c81bf40bebe7dd13 Mon Sep 17 00:00:00 2001 From: Wes Bemont Date: Wed, 9 Sep 2026 16:35:33 +0000 Subject: [PATCH] Harden find_replace.sh CI helper against arg splitting The find/replace helper piped `grep -rl` output into `xargs gsed` using xargs' default whitespace splitting and quote processing, and passed the search pattern to grep/gsed without terminating option parsing. Paths containing spaces (or values beginning with `-`) could be split into multiple arguments or interpreted as options rather than data. Use NUL-delimited matching (`grep -rlZ | xargs -0`) so filenames are passed verbatim, and add `--` after grep's options to end option parsing. Behavior is otherwise unchanged. --- .github/scripts/find_replace.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/find_replace.sh b/.github/scripts/find_replace.sh index ee94ea12084..57074a925f6 100755 --- a/.github/scripts/find_replace.sh +++ b/.github/scripts/find_replace.sh @@ -3,4 +3,4 @@ old_text=$1 new_text=$2 echo "Old text: ${old_text}" echo "New text: ${new_text}" -grep -rl "${old_text}" . | xargs gsed -i -e '1h;2,$H;$!d;g' -e "s/${old_text}/${new_text}/g" +grep -rlZ -- "${old_text}" . | xargs -0 gsed -i -e '1h;2,$H;$!d;g' -e "s/${old_text}/${new_text}/g"