From 382323d0d4c37d98bb4088e2b4541a2a62180fa5 Mon Sep 17 00:00:00 2001 From: "C. Morgan Hamill" Date: Thu, 30 Aug 2018 12:44:11 -0700 Subject: Use shell-style word-splitting on `editor` Use `shlex.split()` on the (possibly user-provided) editor, to avoid passing a nonsensical list to `subprocess.Popen`. Allow use of `plugins.var.python.edit.editor = "vim -c 'set notitle'"`, for example, which previously was passed to `subprocess.Popen` as `["vim", "-c", "'set", "notitle'", path]`. --- edit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/edit.py b/edit.py index f48e0f3..65fcf42 100644 --- a/edit.py +++ b/edit.py @@ -13,6 +13,7 @@ import os import os.path +import shlex import subprocess import weechat @@ -24,7 +25,7 @@ def edit(data, buf, args): with open(path, "w+") as f: f.write(weechat.buffer_get_string(buf, "input")) - cmd = editor.split() + [path] + cmd = shlex.split(editor) + [path] code = subprocess.Popen(cmd).wait() if code != 0: os.remove(path) -- cgit v1.2.3-70-g09d2