fix(url): escape cmd.exe special chars in vim.ui.open() URL #41394

Problem:
On Windows, vim.ui.open() passes URLs to `cmd.exe /c start`. cmd.exe
treats `&` as a command separator, so query strings are truncated.

Solution:
Caret-escape `&|<>^%!` in URIs when the open handler is cmd.exe.
This commit is contained in:
Shubh
2026-08-22 20:19:55 +05:30
committed by GitHub
parent dadaa7fcad
commit f583991553
2 changed files with 24 additions and 0 deletions

View File

@@ -199,6 +199,8 @@ function M.open(path, opt)
if open_cmd[1] == 'xdg-open' then
job_opt.stdout = false
job_opt.stderr = false
elseif open_cmd[1] == 'cmd.exe' and is_uri then
path = path:gsub('([&|<>^%%!])', '^%1') -- Escape cmd.exe special chars. #41337
end
cmd = vim.list_extend(open_cmd, { path })
end