From 31bcc70efbc24bb98a52c4c261f02f5e36f6ee0a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 10 Apr 2015 19:45:59 +0200 Subject: [PATCH] Treat commands using ;; in key config as valid. --- qutebrowser/config/parsers/keyconf.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/qutebrowser/config/parsers/keyconf.py b/qutebrowser/config/parsers/keyconf.py index 5d94a26fc..3d9fc6556 100644 --- a/qutebrowser/config/parsers/keyconf.py +++ b/qutebrowser/config/parsers/keyconf.py @@ -257,15 +257,32 @@ class KeyConfigParser(QObject): self.is_dirty = True self.config_dirty.emit() + def _validate_command(self, line): + """Check if a given command is valid.""" + commands = line.split(';;') + try: + cmd = cmdutils.cmd_dict[commands[0]] + if cmd.no_cmd_split: + commands = [line] + except KeyError: + pass + + for cmd in commands: + if not cmd.strip(): + raise KeyConfigError("Got empty command (line: {!r})!".format( + line)) + commands = [c.split(maxsplit=1)[0].strip() for c in commands] + for cmd in commands: + if cmd not in cmdutils.cmd_dict: + raise KeyConfigError("Invalid command '{}'!".format(cmd)) + def _read_command(self, line): """Read a command from a line.""" if self._cur_section is None: raise KeyConfigError("Got command '{}' without getting a " "section!".format(line)) else: - command = line.split(maxsplit=1)[0] - if command not in cmdutils.cmd_dict: - raise KeyConfigError("Invalid command '{}'!".format(command)) + self._validate_command(line) for rgx, repl in configdata.CHANGED_KEY_COMMANDS: if rgx.match(line): line = rgx.sub(repl, line)