Allow player arguments with spaces/quotes (#665) (#668)

This commit is contained in:
Etoh 2024-01-28 11:34:32 +00:00 committed by GitHub
parent e7b824c124
commit a0a6e6a644
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 3 deletions

View File

@ -115,6 +115,7 @@ LAST_PAUSED_DIFF_THRESHOLD = 2
FILENAME_STRIP_REGEX = "[-~_\.\[\](): ]"
CONTROL_PASSWORD_STRIP_REGEX = "[^a-zA-Z0-9\-]"
ROOM_NAME_STRIP_REGEX = "^(\+)(?P<roomnamebase>.*)(:)(\w{12})$"
ARGUMENT_SPLIT_REGEX = r'(?:[^\s"]+|"[^"]*")+'
COMMANDS_UNDO = ["u", "undo", "revert"]
COMMANDS_CHAT = ["ch", "chat"]
COMMANDS_LIST = ["l", "list", "users"]

View File

@ -487,10 +487,14 @@ class VlcPlayer(BasePlayer):
call.extend(self.__playerController.SLAVE_ARGS)
if args:
call.extend(args)
for arg in args:
if "=" in arg and "\"" in arg:
(argName, argValue) = arg.split("=", 1)
if argValue.startswith("\"") and argValue.endswith("\""):
arg = argName + "=" + argValue[1:-1]
call.extend([arg])
self._vlcVersion = None
if isWindows() and getattr(sys, 'frozen', '') and getattr(sys, '_MEIPASS', '') is not None: # Needed for pyinstaller --onefile bundle
self.__process = subprocess.Popen(
call, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE,

View File

@ -279,7 +279,7 @@ class ConfigDialog(QtWidgets.QDialog):
currentplayerpath = self.executablepathCombobox.currentText()
if currentplayerpath:
NewPlayerArgs = self.playerargsTextbox.text().split(" ") if self.playerargsTextbox.text() else ""
NewPlayerArgs = utils.parseCommandLineString(self.playerargsTextbox.text()) if self.playerargsTextbox.text() else ""
self.perPlayerArgs[self.executablepathCombobox.currentText()] = NewPlayerArgs
def languageChanged(self):

View File

@ -191,6 +191,10 @@ def limitedPowerset(s, minLength):
return itertools.chain.from_iterable(itertools.combinations(s, r) for r in range(len(s), minLength, -1))
def parseCommandLineString(s):
arsToReturn = re.findall(constants.ARGUMENT_SPLIT_REGEX, s)
return arsToReturn
def blackholeStdoutForFrozenWindow():
if getattr(sys, 'frozen', '') == "windows_exe":
class Stderr(object):