Skip to content

fix(#1728): escape cwd changes to prevent environment variable expansion #1729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ function M.on_enter(netrw_disabled)
local is_file = stats and stats.type == "file"
local cwd
if is_dir then
cwd = vim.fn.expand(bufname)
cwd = vim.fn.expand(vim.fn.fnameescape(bufname))
-- INFO: could potentially conflict with rooter plugins
vim.cmd("noautocmd cd " .. cwd)
vim.cmd("noautocmd cd " .. vim.fn.fnameescape(cwd))
end

local lines = not is_dir and vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) or {}
Expand Down
1 change: 1 addition & 0 deletions lua/nvim-tree/actions/root/change-dir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local M = {
}

local function clean_input_cwd(name)
name = vim.fn.fnameescape(name)
local root_parent_cwd = vim.fn.fnamemodify(utils.path_remove_trailing(core.get_cwd()), ":h")
if name == ".." and root_parent_cwd then
return vim.fn.expand(root_parent_cwd)
Expand Down