diff options
| author | Luke Kershaw <35707277+l-kershaw@users.noreply.github.com> | 2021-08-19 18:09:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-19 19:09:14 +0200 |
| commit | 161a2e9f61f13c84cc404177a5f5c12e1329666f (patch) | |
| tree | 07e9280ca06f471bf8b5ce011bed6cc8f0fa10eb /lua/telescope/command.lua | |
| parent | f67d3e883d7afafa93428a27cb1ba1c4144d9d4c (diff) | |
fix(command parser): discard invalid lua expressions (#1124)
Diffstat (limited to 'lua/telescope/command.lua')
| -rw-r--r-- | lua/telescope/command.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lua/telescope/command.lua b/lua/telescope/command.lua index 01ed3c6..8d47f5a 100644 --- a/lua/telescope/command.lua +++ b/lua/telescope/command.lua @@ -97,10 +97,16 @@ local function convert_user_opts(user_opts) if ok then user_opts[key] = eval else - eval = assert(loadstring("return " .. val))() - if type(eval) == "table" then + local err + 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 else + -- otherwise return nil (allows split check later) user_opts[key] = nil end end |
