Skip to content

Commit

Permalink
Allow player arguments with spaces/quotes (#665) (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
Et0h authored Jan 28, 2024
1 parent e7b824c commit a0a6e6a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions syncplay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def getValueForOS(constantDict):
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"]
Expand Down
8 changes: 6 additions & 2 deletions syncplay/players/vlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,14 @@ def _createIntfFolder(vlcSyncplayInterfaceDir):

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,
Expand Down
2 changes: 1 addition & 1 deletion syncplay/ui/GuiConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def changedPlayerArgs(self):
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):
Expand Down
4 changes: 4 additions & 0 deletions syncplay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a0a6e6a

Please sign in to comment.