Skip to content

Commit

Permalink
fix(usercmd): add input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Jan 21, 2025
1 parent 441dbf0 commit 33dbf7a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lua/cord/api/usercmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,20 @@ M.get_features = function()
end

M.handle = function(q_args)
local args = vim.split(q_args:gsub('"', ''), '%s+')
if not q_args then
require('cord.plugin.log').log_raw(vim.log.levels.ERROR, 'No command provided')
return
end

if type(q_args) ~= 'string' then
require('cord.plugin.log').log_raw(
vim.log.levels.ERROR,
'Invalid input: expected string, got ' .. tostring(q_args)
)
return
end

local args = vim.split(string.gsub(q_args, '"', ''), '%s+')
local args_len = #args
if args_len == 0 then
require('cord.plugin.log').log_raw(vim.log.levels.ERROR, 'No command provided')
Expand Down

0 comments on commit 33dbf7a

Please sign in to comment.