fix(vim.secure): read() command injection vulnerability #39918

Problem:
Malicious filename can execute code because of ":" cmdline expansion.

Solution:
Use `fnameescape()`.

fix https://github.com/neovim/neovim/issues/39914
This commit is contained in:
Justin M. Keyes
2026-05-20 15:27:43 -04:00
committed by GitHub
parent 24e00f2844
commit 799cbfff85
2 changed files with 29 additions and 1 deletions

View File

@@ -151,7 +151,7 @@ function M.read(path)
return nil
elseif result == 2 then
-- View
vim.cmd('sview ' .. fullpath)
vim.cmd(('sview %s'):format(vim.fn.fnameescape(fullpath)))
return nil
elseif result == 3 then
-- Deny