From 6573114a289b1b0772dadb71b7cc86686614eb51 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Mon, 20 May 2024 08:11:24 -0700 Subject: [PATCH] fix(manpages): safety for malformed entries (closes #1208) --- lua/fzf-lua/actions.lua | 5 ++--- lua/fzf-lua/libuv.lua | 2 +- lua/fzf-lua/providers/manpages.lua | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/fzf-lua/actions.lua b/lua/fzf-lua/actions.lua index a4a23b4d..3c6e1612 100644 --- a/lua/fzf-lua/actions.lua +++ b/lua/fzf-lua/actions.lua @@ -91,9 +91,8 @@ M.resume = function(_, _) end M.vimcmd = function(vimcmd, selected, noesc) - for i = 1, #selected do - vim.cmd(("%s %s"):format(vimcmd, - noesc and selected[i] or vim.fn.fnameescape(selected[i]))) + for _, sel in ipairs(selected) do + vim.cmd(("%s %s"):format(vimcmd, noesc and sel or vim.fn.fnameescape(sel))) end end diff --git a/lua/fzf-lua/libuv.lua b/lua/fzf-lua/libuv.lua index d2f06d28..2d709818 100644 --- a/lua/fzf-lua/libuv.lua +++ b/lua/fzf-lua/libuv.lua @@ -648,7 +648,7 @@ M.shellescape = function(s, win_style) else local ret = nil vim.o.shell = "sh" - if not s:match([["]]) and not s:match([[\]]) then + if s and not s:match([["]]) and not s:match([[\]]) then -- if the original string does not contain double quotes, -- replace surrounding single quote with double quotes, -- temporarily replace all single quotes with double diff --git a/lua/fzf-lua/providers/manpages.lua b/lua/fzf-lua/providers/manpages.lua index 794e9493..85603a7a 100644 --- a/lua/fzf-lua/providers/manpages.lua +++ b/lua/fzf-lua/providers/manpages.lua @@ -16,7 +16,8 @@ end --- @param apropos_line string --- @return string arg without shellescape M.manpage_vim_arg = function(apropos_line) - return string.format("%s(%s)", parse_apropos(apropos_line)) + local page, section = parse_apropos(apropos_line) + return string.format("%s(%s)", page, section) end --- @param apropos_line string --- @return string arg with shellescape