Skip to content

Commit

Permalink
boxes_proxy: Create list to avoid quoting issues
Browse files Browse the repository at this point in the history
Creating a command string just to split it up before executing it is
just asking for trouble. Create the list right away.

Resolves: #743
  • Loading branch information
florianfesti committed Jan 11, 2025
1 parent d83609e commit 729ef03
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions boxes/scripts/boxes_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def add_arguments(self, pars):
pars.add_argument(key, default=key)

def generate(self):
cmd = "boxes" # boxes.exe in this local dir (or if present in %PATH%), or boxes from $PATH in linux
cmd = ["boxes"] # boxes.exe in this local dir (or if present in %PATH%), or boxes from $PATH in linux
for arg in vars(self.options):
if arg in (
"output", "id", "ids", "selected_nodes",
Expand All @@ -47,12 +47,15 @@ def generate(self):
# interpreted if set to false
if arg == "original" and str(getattr(self.options, arg)) == "false":
continue
cmd += f" --{arg} {quote(str(getattr(self.options, arg)))}"
cmd += f" --output -"
cmd = cmd.replace("boxes --generator", "boxes")
if arg == "generator":
cmd.append(str(getattr(self.options, arg)))
continue
cmd.extend([f"--{arg}", str(getattr(self.options, arg))])
cmd += ["--output", "-"]

#print(repr(cmd), file=sys.stderr)
# run boxes with the parameters provided
result = subprocess.run(cmd.split(), capture_output=True)
result = subprocess.run(cmd, capture_output=True)

if result.returncode:
inkex.utils.debug("Generating box svg failed. Cannot continue. Command was:")
Expand Down

0 comments on commit 729ef03

Please sign in to comment.