This revision was automatically updated to reflect the committed changes. Closed by commit rGb42d51ba9ad1: [lldb/test] Replace shlex.join with shlex.quote (authored by labath).
Changed prior to commit: https://reviews.llvm.org/D112802?vs=383301&id=383302#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112802/new/ https://reviews.llvm.org/D112802 Files: lldb/packages/Python/lldbsuite/support/seven.py lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/packages/Python/lldbsuite/test_event/build_exception.py Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py =================================================================== --- lldb/packages/Python/lldbsuite/test_event/build_exception.py +++ lldb/packages/Python/lldbsuite/test_event/build_exception.py @@ -1,10 +1,10 @@ -import shlex +from lldbsuite.support import seven class BuildError(Exception): def __init__(self, called_process_error): super(BuildError, self).__init__("Error when building test subject") - self.command = shlex.join(called_process_error.cmd) + self.command = seven.join_for_shell(called_process_error.cmd) self.build_error = called_process_error.output def __str__(self): Index: lldb/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -45,7 +45,6 @@ import re import shutil import signal -import shlex from subprocess import * import sys import time @@ -68,6 +67,7 @@ from . import test_categories from lldbsuite.support import encoded_file from lldbsuite.support import funcutils +from lldbsuite.support import seven from lldbsuite.test.builders import get_builder from lldbsuite.test_event import build_exception @@ -1423,7 +1423,7 @@ self.runBuildCommand(command) def runBuildCommand(self, command): - self.trace(shlex.join(command)) + self.trace(seven.join_for_shell(command)) try: output = check_output(command, stderr=STDOUT, errors="replace") except CalledProcessError as cpe: Index: lldb/packages/Python/lldbsuite/support/seven.py =================================================================== --- lldb/packages/Python/lldbsuite/support/seven.py +++ lldb/packages/Python/lldbsuite/support/seven.py @@ -1,5 +1,6 @@ import binascii import six +import shlex if six.PY2: import commands @@ -49,3 +50,7 @@ def hexlify(data): """Hex-encode string data. The result if always a string.""" return bitcast_to_string(binascii.hexlify(bitcast_to_bytes(data))) + +# TODO: Replace this with `shlex.join` when minimum Python version is >= 3.8 +def join_for_shell(split_command): + return " ".join([shlex.quote(part) for part in split_command])
Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py =================================================================== --- lldb/packages/Python/lldbsuite/test_event/build_exception.py +++ lldb/packages/Python/lldbsuite/test_event/build_exception.py @@ -1,10 +1,10 @@ -import shlex +from lldbsuite.support import seven class BuildError(Exception): def __init__(self, called_process_error): super(BuildError, self).__init__("Error when building test subject") - self.command = shlex.join(called_process_error.cmd) + self.command = seven.join_for_shell(called_process_error.cmd) self.build_error = called_process_error.output def __str__(self): Index: lldb/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -45,7 +45,6 @@ import re import shutil import signal -import shlex from subprocess import * import sys import time @@ -68,6 +67,7 @@ from . import test_categories from lldbsuite.support import encoded_file from lldbsuite.support import funcutils +from lldbsuite.support import seven from lldbsuite.test.builders import get_builder from lldbsuite.test_event import build_exception @@ -1423,7 +1423,7 @@ self.runBuildCommand(command) def runBuildCommand(self, command): - self.trace(shlex.join(command)) + self.trace(seven.join_for_shell(command)) try: output = check_output(command, stderr=STDOUT, errors="replace") except CalledProcessError as cpe: Index: lldb/packages/Python/lldbsuite/support/seven.py =================================================================== --- lldb/packages/Python/lldbsuite/support/seven.py +++ lldb/packages/Python/lldbsuite/support/seven.py @@ -1,5 +1,6 @@ import binascii import six +import shlex if six.PY2: import commands @@ -49,3 +50,7 @@ def hexlify(data): """Hex-encode string data. The result if always a string.""" return bitcast_to_string(binascii.hexlify(bitcast_to_bytes(data))) + +# TODO: Replace this with `shlex.join` when minimum Python version is >= 3.8 +def join_for_shell(split_command): + return " ".join([shlex.quote(part) for part in split_command])
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits