diff --git a/qutebrowser/commands/runners.py b/qutebrowser/commands/runners.py index ad9ae9f08..d1f15a415 100644 --- a/qutebrowser/commands/runners.py +++ b/qutebrowser/commands/runners.py @@ -119,6 +119,9 @@ class CommandRunner(QObject): Yields: ParseResult tuples. """ + if not text: + raise cmdexc.NoSuchCommandError("No command given") + if aliases: text = self._get_alias(text, text) diff --git a/tests/unit/commands/test_runners.py b/tests/unit/commands/test_runners.py index 10da730ae..a16ad764a 100644 --- a/tests/unit/commands/test_runners.py +++ b/tests/unit/commands/test_runners.py @@ -53,6 +53,15 @@ class TestCommandRunner: with pytest.raises(cmdexc.NoSuchCommandError): list(cr.parse_all("alias_name")) + def test_parse_empty_with_alias(self): + """An empty command should not crash. + + See https://github.com/The-Compiler/qutebrowser/issues/1690 + """ + cr = runners.CommandRunner(0) + with pytest.raises(cmdexc.NoSuchCommandError): + list(cr.parse_all('')) + def test_parse_with_count(self): """Test parsing of commands with a count.""" cr = runners.CommandRunner(0)