Skip to content

Commit e204a7d

Browse files
authored
fix(#1728): escape cwd changes to prevent environment variable expansion (#1729)
1 parent bcb2a5a commit e204a7d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lua/nvim-tree.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ function M.on_enter(netrw_disabled)
226226
local is_file = stats and stats.type == "file"
227227
local cwd
228228
if is_dir then
229-
cwd = vim.fn.expand(bufname)
229+
cwd = vim.fn.expand(vim.fn.fnameescape(bufname))
230230
-- INFO: could potentially conflict with rooter plugins
231-
vim.cmd("noautocmd cd " .. cwd)
231+
vim.cmd("noautocmd cd " .. vim.fn.fnameescape(cwd))
232232
end
233233

234234
local lines = not is_dir and vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) or {}

lua/nvim-tree/actions/root/change-dir.lua

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ local M = {
77
}
88

99
local function clean_input_cwd(name)
10+
name = vim.fn.fnameescape(name)
1011
local root_parent_cwd = vim.fn.fnamemodify(utils.path_remove_trailing(core.get_cwd()), ":h")
1112
if name == ".." and root_parent_cwd then
1213
return vim.fn.expand(root_parent_cwd)

0 commit comments

Comments
 (0)