mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 17:43:52 +01:00
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
This commit is contained in:
parent
44ddd2e8f5
commit
fa468ce9d1
1 changed files with 10 additions and 1 deletions
|
|
@ -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`.
|
||||
|
|
|
|||
Loading…
Reference in a new issue