From 77d38011b5bea024357263a67f4d4da1189cbaa9 Mon Sep 17 00:00:00 2001 From: magical Date: Sat, 6 Aug 2022 08:53:58 +0000 Subject: [PATCH] quote file path in shell command --- clients/urwid/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clients/urwid/main.py b/clients/urwid/main.py index 535e1b8..28e1287 100644 --- a/clients/urwid/main.py +++ b/clients/urwid/main.py @@ -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)