[alacarte] ItemEditor: Fix bad command validation
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [alacarte] ItemEditor: Fix bad command validation
- Date: Fri, 18 Apr 2014 14:06:17 +0000 (UTC)
commit 665b4715000e4f6b55db0e23ca100c56f3be4455
Author: OmegaPhil <OmegaPhil+GNOME-bugs gmail com>
Date: Fri Apr 18 08:25:00 2014 -0400
ItemEditor: Fix bad command validation
When the Exec line has multiple components, we need to parse it
and only check the first one.
https://bugzilla.gnome.org/show_bug.cgi?id=728372
Alacarte/ItemEditor.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/Alacarte/ItemEditor.py b/Alacarte/ItemEditor.py
index 3b48324..e89c0ff 100644
--- a/Alacarte/ItemEditor.py
+++ b/Alacarte/ItemEditor.py
@@ -179,10 +179,24 @@ class LauncherEditor(ItemEditor):
self.builder.get_object('name-entry').connect('changed', self.resync_validity)
self.builder.get_object('exec-entry').connect('changed', self.resync_validity)
+ def exec_line_is_valid(self, exec_text):
+ try:
+ # Attempting to parse command - commands are not simply program names or paths... Errors are
raised for blank or invalid input (e.g. missing closing quote)
+ result = GLib.shell_parse_argv(exec_text)
+ if result[0]:
+ # Parsing succeeded - making sure program (first part of the command) is in the path
+ command = result[1][0]
+ return (GLib.find_program_in_path(command) is not None)
+ else:
+ # Parsing failure, but not reported via raised GError?
+ return False
+ except GLib.GError:
+ return False
+
def resync_validity(self, *args):
name_text = self.builder.get_object('name-entry').get_text()
exec_text = self.builder.get_object('exec-entry').get_text()
- valid = (name_text != "" and GLib.find_program_in_path(exec_text) is not None)
+ valid = (name_text != "" and self.exec_line_is_valid(exec_text))
self.builder.get_object('ok').set_sensitive(valid)
def load(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]