fix(api): validate user_command name (#17004)

The name argument of nvim_add_user_command must begin with an uppercase
character. Check that is does.
This commit is contained in:
Lewis Russell 2022-01-09 15:54:03 +00:00 committed by GitHub
parent 8d5288889a
commit a34652ee84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1387,6 +1387,11 @@ void add_user_command(String name, Object command, Dict(user_command) *opts, int
LuaRef luaref = LUA_NOREF;
LuaRef compl_luaref = LUA_NOREF;
if (mb_islower(name.data[0])) {
api_set_error(err, kErrorTypeValidation, "'name' must begin with an uppercase letter");
goto err;
}
if (HAS_KEY(opts->range) && HAS_KEY(opts->count)) {
api_set_error(err, kErrorTypeValidation, "'range' and 'count' are mutually exclusive");
goto err;