aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2023-07-27 23:54:16 -0400
committerGreg Hudson <ghudson@mit.edu>2023-08-22 01:35:44 -0400
commitae704daad5caa502387aa39ed6d596cb117d5b3a (patch)
tree156b452d58424a7cd16d494b96bb968c6e3fda15
parent88a1701b423c13991a8064feeb26952d3641d840 (diff)
downloadkrb5-ae704daad5caa502387aa39ed6d596cb117d5b3a.zip
krb5-ae704daad5caa502387aa39ed6d596cb117d5b3a.tar.gz
krb5-ae704daad5caa502387aa39ed6d596cb117d5b3a.tar.bz2
Properly quote command strings in k5test.py
Requiring Python 3.4 gives us shlex.quote() (added in Python 3.3). Use it in _shell_equiv() to quote command arguments.
-rw-r--r--src/util/k5test.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/util/k5test.py b/src/util/k5test.py
index 8e5f5ba..f205f0a 100644
--- a/src/util/k5test.py
+++ b/src/util/k5test.py
@@ -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