mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 05:48:17 +00:00
fix(api): validate command names in nvim_add_user_command (#17406)
This uses the same validation used when defining commands with `:command`.
This commit is contained in:
@@ -1384,6 +1384,11 @@ void add_user_command(String name, Object command, Dict(user_command) *opts, int
|
||||
LuaRef luaref = LUA_NOREF;
|
||||
LuaRef compl_luaref = LUA_NOREF;
|
||||
|
||||
if (!uc_validate_name(name.data)) {
|
||||
api_set_error(err, kErrorTypeValidation, "Invalid command name");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (mb_islower(name.data[0])) {
|
||||
api_set_error(err, kErrorTypeValidation, "'name' must begin with an uppercase letter");
|
||||
goto err;
|
||||
|
Reference in New Issue
Block a user