Skip to content

Commit

Permalink
Properly quote command strings in k5test.py
Browse files Browse the repository at this point in the history
Requiring Python 3.4 gives us shlex.quote() (added in Python 3.3).
Use it in _shell_equiv() to quote command arguments.
  • Loading branch information
greghudson committed Aug 22, 2023
1 parent 88a1701 commit ae704da
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/util/k5test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ae704da

Please sign in to comment.