From 74b45aea47a0a5dae2548ee17305dec0e710d32b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 13 Sep 2014 00:42:16 +0200 Subject: [PATCH] conftypes: Better handling of ShellCommand. --- qutebrowser/config/configtypes.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index fada5ae1b..82b94ee3c 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -909,7 +909,7 @@ class WebKitBytesList(List): "set!".format(self.length)) -class ShellCommand(String): +class ShellCommand(BaseType): """A shellcommand which is split via shlex. @@ -920,7 +920,7 @@ class ShellCommand(String): typestr = 'shell-command' def __init__(self, placeholder=False, none_ok=False): - super().__init__(none_ok=none_ok) + super().__init__(none_ok) self.placeholder = placeholder def validate(self, value): @@ -929,9 +929,12 @@ class ShellCommand(String): return else: raise ValidationError(value, "may not be empty!") - super().validate(value) if self.placeholder and '{}' not in self.transform(value): raise ValidationError(value, "needs to contain a {}-placeholder.") + try: + shlex.split(value) + except ValueError as e: + raise ValidationError(value, str(e)) def transform(self, value): if not value: