1
Fork 0
mirror of https://github.com/j1g5awi/krunner-vscode.git synced 2024-11-21 13:29:29 +00:00

Use subprocess to run VSCode (#5)

This removes the risk of any shell injection from `os.system`.
This commit is contained in:
Jake Howard 2023-08-07 05:13:40 +01:00 committed by GitHub
parent e2cbbcd1f4
commit ea2aba100f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()