diff options
author | Florian Bruhin <git@the-compiler.org> | 2015-04-10 19:45:59 +0200 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2015-04-10 19:45:59 +0200 |
commit | 31bcc70efbc24bb98a52c4c261f02f5e36f6ee0a (patch) | |
tree | b57c4e45a14f837ffee2cf762c4295d5a0de423e | |
parent | f865b87a749e185088921dffda03aebad5886493 (diff) | |
download | qutebrowser-31bcc70efbc24bb98a52c4c261f02f5e36f6ee0a.tar.gz qutebrowser-31bcc70efbc24bb98a52c4c261f02f5e36f6ee0a.zip |
Treat commands using ;; in key config as valid.
-rw-r--r-- | qutebrowser/config/parsers/keyconf.py | 23 |
1 files 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) |