diff options
author | monsta <[email protected]> | 2016-02-16 17:27:04 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2016-02-16 17:37:55 +0300 |
commit | 4d84579eace005ab4ab07646bc693da22c75bfc4 (patch) | |
tree | b41dbd422f07f302e33c52efa36daa622c2c7c6f | |
parent | 6da08950252f01626a4c39316890e6386e5a9f9e (diff) | |
download | pluma-4d84579eace005ab4ab07646bc693da22c75bfc4.tar.bz2 pluma-4d84579eace005ab4ab07646bc693da22c75bfc4.tar.xz |
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
-rw-r--r-- | plugins/externaltools/data/switch-c.tool.in | 11 |
1 files changed, 9 insertions, 2 deletions
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]) |