diff --git a/gitosis/serve.py b/gitosis/serve.py index 4b7c6a7..551ac46 100644 --- a/gitosis/serve.py +++ b/gitosis/serve.py @@ -54,7 +54,11 @@ def serve( if '\n' in command: raise CommandMayNotContainNewlineError() - verb, args = command.split(None, 1) + try: + verb, args = command.split(None, 1) + except ValueError: + # all known commands take one argument; improve if/when needed + raise UnknownCommandError() if (verb not in COMMANDS_WRITE and verb not in COMMANDS_READONLY): diff --git a/gitosis/test/test_serve.py b/gitosis/test/test_serve.py index a79dbaf..416587a 100644 --- a/gitosis/test/test_serve.py +++ b/gitosis/test/test_serve.py @@ -21,6 +21,18 @@ def test_bad_newLine(): eq(str(e), 'Command may not contain newline') assert isinstance(e, serve.ServingError) +def test_bad_nospace(): + cfg = RawConfigParser() + e = assert_raises( + serve.UnknownCommandError, + serve.serve, + cfg=cfg, + user='jdoe', + command='git-upload-pack', + ) + eq(str(e), 'Unknown command denied') + assert isinstance(e, serve.ServingError) + def test_bad_command(): cfg = RawConfigParser() e = assert_raises(