quote file path in shell command

master
magical 2022-08-06 08:53:58 +00:00
parent 4364c16625
commit 77d38011b5
1 changed files with 3 additions and 2 deletions

View File

@ -33,6 +33,7 @@ from sys import exit
import rlcompleter
import readline
import tempfile
import shlex
import urwid
import json
import os
@ -1603,7 +1604,7 @@ class App(object):
_.write(init_body)
env = os.environ.copy()
env['LANG'] = 'en_US.UTF-8'
call("%s %s" % (self.prefs["editor"], path), env=env, shell=True)
call("%s %s" % (self.prefs["editor"], shlex.quote(path)), env=env, shell=True)
with open(path) as _:
body = _.read()
os.remove(path)
@ -1958,7 +1959,7 @@ class ExternalEditor(urwid.Terminal):
# should use the options menu to switch to Overthrow mode.
env.update({"LANG": "POSIX"})
command = ["bash", "-c", "{} {}; echo Press any key to kill this window...".format(
app.prefs["editor"], self.path)]
app.prefs["editor"], shlex.quote(self.path))]
super(ExternalEditor, self).__init__(command, env, app.loop, app.prefs["edit_escapes"]["abort"])
urwid.connect_signal(self, "closed", self.exterminate)