summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2016-07-27 11:19:01 +0200
committerFlorian Bruhin <git@the-compiler.org>2016-07-27 11:23:30 +0200
commita84807ed05115fb690f300ab77f1742f577c907c (patch)
treee25ace164d1e9f59d5dac8cebae1118e4c30109d
parent2795ae947817f494c58b49959346b48779bb077c (diff)
downloadqutebrowser-a84807ed05115fb690f300ab77f1742f577c907c.tar.gz
qutebrowser-a84807ed05115fb690f300ab77f1742f577c907c.zip
Handle empty command in CommandRunner.parse_all
Sicne we now call self._get_alias there, we also need to make sure it's not an empty string before that. Introduced in #1577. Fixes #1690.
-rw-r--r--qutebrowser/commands/runners.py3
-rw-r--r--tests/unit/commands/test_runners.py9
2 files changed, 12 insertions, 0 deletions
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)