From ea2aba100f0e1e5cdcae166909369ef750497563 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 7 Aug 2023 05:13:40 +0100 Subject: [PATCH] Use subprocess to run VSCode (#5) This removes the risk of any shell injection from `os.system`. --- krunner_vscode/__main__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/krunner_vscode/__main__.py b/krunner_vscode/__main__.py index e4de460..0fa5cc4 100755 --- a/krunner_vscode/__main__.py +++ b/krunner_vscode/__main__.py @@ -1,5 +1,6 @@ import json import os +import subprocess import sqlite3 from pathlib import Path from typing import NamedTuple @@ -92,11 +93,10 @@ class Runner(dbus.service.Object): @dbus.service.method(iface, in_signature="ss") def Run(self, data: str, action_id: str): - if not action_id: - os.system("code " + data) - else: - os.system("xdg-open " + data) - + subprocess.run([ + "code" if not action_id else "xdg-open", + data + ]) runner = Runner() loop = GLib.MainLoop()