Commit 1df00237 for xz
commit 1df00237ae36da1debd5f30ca76a78e28a10d6e2
Author: Lasse Collin <lasse.collin@tukaani.org>
Date: Mon May 25 18:32:15 2026 +0300
xzgrep: Fix handling of the ' char at the end of an option
For example, the following would run the "id" command:
xzgrep "--a='" "--b=;id;'" "pattern" foo.xz
The bug was inherited from gzip's zgrep. It was reported to bug-gzip by
Leenear. It was fixed in gzip in the commit cd74dc30f8cc by Paul Eggert.
Link: https://lists.gnu.org/archive/html/bug-gzip/2026-04/msg00032.html
diff --git a/src/scripts/xzgrep.in b/src/scripts/xzgrep.in
index 511ea39c..46205512 100644
--- a/src/scripts/xzgrep.in
+++ b/src/scripts/xzgrep.in
@@ -147,7 +147,7 @@ while test $# -ne 0; do
esac
case $option in
- (*\'?*)
+ (*\'*)
option=\'$(printf '%sX\n' "$option" | LC_ALL=C sed "$escape");;
(*)
option="'$option'";;