Permalink
Browse files

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.
  • Loading branch information...
The-Compiler committed Jul 27, 2016
1 parent be609d5 commit 9ff006746fb75de6fdff1aaa2329ccb7b29eb51c
Showing with 12 additions and 0 deletions.
  1. +3 −0 qutebrowser/commands/runners.py
  2. +9 −0 tests/unit/commands/test_runners.py
@@ -119,6 +119,9 @@ def parse_all(self, text, aliases=True, *args, **kwargs):
Yields:
ParseResult tuples.
"""
if not text:
raise cmdexc.NoSuchCommandError("No command given")
if aliases:
text = self._get_alias(text, text)
@@ -53,6 +53,15 @@ def test_parse_all_with_alias(self, cmdline_test, config_stub):
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)

0 comments on commit 9ff0067

Please sign in to comment.