fix(zip): keep a leading dash from becoming a backend option

This commit is contained in:
Barrett Ruth
2026-07-24 16:28:16 -07:00
parent e29af9c32f
commit e63cf57106
2 changed files with 20 additions and 1 deletions

View File

@@ -18,7 +18,14 @@ end
---@param value string
---@return string
local function literal_pattern(value)
return (value:gsub('\\', '\\\\'):gsub('%?', '\\?'):gsub('%*', '\\*'):gsub('%[', '[[]'))
return (
value
:gsub('\\', '\\\\')
:gsub('%?', '\\?')
:gsub('%*', '\\*')
:gsub('%[', '[[]')
:gsub('^%-', '[-]')
)
end
---@param source string

View File

@@ -271,6 +271,18 @@ describe('nvim.zip', function()
end
end)
it('keeps a leading dash in a member from becoming a backend option', function()
local archive = vim.fs.joinpath(root, 'poc.zip')
copy_fixture(vim.fs.joinpath(old_samples, 'poc.zip'), archive)
clear_zip()
edit(archive)
eq({ '-d/', 'pwned' }, lines())
edit(('zipfile://%s::-d/tmp'):format(archive))
eq({ '' }, lines())
end)
it('treats archive glob characters literally', function()
t.skip(t.is_os('win'), 'N/A: Windows filenames cannot contain these characters')
local archive = vim.fs.joinpath(root, 'archive::[*?].zip')