Properly quote executable and command line parameter
Use shlex.quote (on python3) or pipes.quote (on python2) to properly
quote the python executable and parameter instead of using single quotes
@@ -28,6 +28,15 @@ from beets.mediafile import MediaFile
from beets import util
+def shell_quote(text):
+ if sys.version_info[0] < 3:
+ import pipes
+ return pipes.quote(text)
+ else:
+ import shlex
+ return shlex.quote(text)
+
+
class TestHelper(helper.TestHelper):
def tagged_copy_cmd(self, tag):
@@ -40,7 +49,7 @@ class TestHelper(helper.TestHelper):
# A Python script that copies the file and appends a tag.
stub = os.path.join(_common.RSRC, b'convert_stub.py').decode('utf-8')
- return u"'{}' '{}' $source $dest {}".format(sys.executable, stub, tag)
+ return u"{} {} $source $dest {}".format(shell_quote(sys.executable), shell_quote(stub), tag)
def assertFileTag(self, path, tag): # noqa
"""Assert that the path is a file and the files content ends with `tag`.
