From f3c19ba7fa437a2512db5261742a494769f46b56 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 11 Feb 2018 20:35:21 +1100 Subject: [PATCH] Prevent whitespaces in command names Fixes #1843 --- src/commands.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/commands.cc b/src/commands.cc index de7d0c98a..8e58a7e6e 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -842,6 +842,9 @@ void define_command(const ParametersParser& parser, Context& context, const Shel const String& cmd_name = parser[0]; auto& cm = CommandManager::instance(); + if (contains_that(cmd_name, is_blank)) + throw runtime_error(format("invalid command name: '{}'", cmd_name)); + if (cm.command_defined(cmd_name) and not parser.get_switch("allow-override")) throw runtime_error(format("command '{}' already defined", cmd_name));