feat(zip): checkhealth and encrypted entries

Problem:
There is no health check. Encrypted entries cannot be read at all, since
Info-ZIP takes a password only from a terminal and `-P` would expose it
in the process arguments.

Solution:
Add `:checkhealth nvim.zip`, reporting the backend and which
implementation is handling archives. Prompt for the password on a pty,
extracting to a file so the entry's bytes stay off the terminal. Report
Info-ZIP's exit code rather than inferring a cause, so an archive using
AES is not reported as a failed decryption.
This commit is contained in:
Barrett Ruth
2026-08-01 14:55:02 -05:00
parent 866d61e91a
commit d03b4cfb7a
5 changed files with 212 additions and 21 deletions

View File

@@ -407,6 +407,37 @@ describe('nvim.zip', function()
end)
end)
it('prompts for the password of an encrypted archive', function()
local archive = stage(fixtures, 'encrypted.zip')
clear_zip()
edit(archive)
eq({ 'secret.txt' }, lines())
-- The password is queued first, so that the prompt consumes it from typeahead.
exec_lua(function(uri)
vim.api.nvim_input('hunter2<CR>')
vim.api.nvim_cmd({ cmd = 'edit', args = { uri }, magic = { file = false, bar = false } }, {})
end, ('zipfile://%s::secret.txt'):format(archive))
poke_eventloop()
eq({ 'secret content' }, lines())
end)
it('reports an incorrect archive password', function()
local archive = stage(fixtures, 'encrypted.zip')
clear_zip()
-- Info-ZIP allows three attempts before giving up.
exec_lua(function(uri)
vim.api.nvim_input('no1<CR>no2<CR>no3<CR>')
vim.api.nvim_cmd({ cmd = 'edit', args = { uri }, magic = { file = false, bar = false } }, {})
end, ('zipfile://%s::secret.txt'):format(archive))
poke_eventloop()
eq(true, exec_capture('messages'):find('incorrect password', 1, true) ~= nil)
end)
describe('extract', function()
--- Stage an archive, restart with the cwd inside the test directory, and open it.
local function open_in_cwd(source_dir, source)