From 4d84579eace005ab4ab07646bc693da22c75bfc4 Mon Sep 17 00:00:00 2001 From: monsta Date: Tue, 16 Feb 2016 17:27:04 +0300 Subject: plugins: make switch-c tool in external tools work, fix issues - specify encoding to let the tool actually run - avoid shell command injection - update copyright thanks to @clefebvre for the fix --- plugins/externaltools/data/switch-c.tool.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/externaltools/data/switch-c.tool.in b/plugins/externaltools/data/switch-c.tool.in index 640c4f02..f9a2ffeb 100644 --- a/plugins/externaltools/data/switch-c.tool.in +++ b/plugins/externaltools/data/switch-c.tool.in @@ -1,5 +1,7 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # Copyright © 2011 Perberos +# Copyright © 2012-2016 MATE developers # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the @@ -16,10 +18,15 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os +import subprocess name = os.environ["PLUMA_CURRENT_DOCUMENT_NAME"] +filename, ext = os.path.splitext(name) if name.endswith('.c'): - os.system("pluma %s.h" % ".".join(name.split('.')[:-1])) + filename = "%s.h" % filename + subprocess.Popen(["pluma", filename]) + if name.endswith('.h'): - os.system("pluma %s.c" % ".".join(name.split('.')[:-1])) + filename = "%s.c" % filename + subprocess.Popen(["pluma", filename]) -- cgit v1.2.1