fix(command parser): discard invalid lua expressions (#1124)

This commit is contained in:
Luke Kershaw
2021-08-19 18:09:14 +01:00
committed by GitHub
parent f67d3e883d
commit 161a2e9f61

View File

@@ -97,10 +97,16 @@ local function convert_user_opts(user_opts)
if ok then if ok then
user_opts[key] = eval user_opts[key] = eval
else else
eval = assert(loadstring("return " .. val))() local err
if type(eval) == "table" then eval, err = loadstring("return " .. val)
if err ~= nil then
-- discard invalid lua expression
user_opts[key] = nil
elseif select("#", assert(eval)()) == 1 and type(assert(eval)()) == "table" then
-- allow if return a single table only
user_opts[key] = eval user_opts[key] = eval
else else
-- otherwise return nil (allows split check later)
user_opts[key] = nil user_opts[key] = nil
end end
end end