]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Properly quote command strings in k5test.py 1308/head
authorGreg Hudson <ghudson@mit.edu>
Fri, 28 Jul 2023 03:54:16 +0000 (23:54 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 22 Aug 2023 05:35:44 +0000 (01:35 -0400)
Requiring Python 3.4 gives us shlex.quote() (added in Python 3.3).
Use it in _shell_equiv() to quote command arguments.

src/util/k5test.py

index 8e5f5ba8e9efd317bf9d40984cb7c57ef99f1cc5..f205f0ab38bae1af0ab949a8ccdee137670dca87 100644 (file)
@@ -672,11 +672,10 @@ def _cfg_merge(cfg1, cfg2):
     return result
 
 
-# Python gives us shlex.split() to turn a shell command into a list of
-# arguments, but oddly enough, not the easier reverse operation.  For
-# now, do a bad job of faking it.
+# We would like to use shlex.join() from Python 3.8.  For now use
+# shlex.quote() from Python 3.3.
 def _shell_equiv(args):
-    return " ".join(args)
+    return ' '.join(shlex.quote(x) for x in args)
 
 
 # Add a valgrind prefix to the front of args if specified in the