mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(path): accept special characters on Windows (#25424)
This commit is contained in:
parent
e72b546354
commit
1e7e9ee91f
@ -648,11 +648,13 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
|
|||||||
}
|
}
|
||||||
s = p + 1;
|
s = p + 1;
|
||||||
} else if (path_end >= path + wildoff
|
} else if (path_end >= path + wildoff
|
||||||
|
#ifdef MSWIN
|
||||||
|
&& vim_strchr("*?[~", (uint8_t)(*path_end)) != NULL
|
||||||
|
#else
|
||||||
&& (vim_strchr("*?[{~$", (uint8_t)(*path_end)) != NULL
|
&& (vim_strchr("*?[{~$", (uint8_t)(*path_end)) != NULL
|
||||||
#ifndef MSWIN
|
|| (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char(path_end))))
|
||||||
|| (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char(path_end)))
|
|
||||||
#endif
|
#endif
|
||||||
)) { // NOLINT(whitespace/parens)
|
) { // NOLINT(whitespace/parens)
|
||||||
e = p;
|
e = p;
|
||||||
}
|
}
|
||||||
len = (size_t)(utfc_ptr2len(path_end));
|
len = (size_t)(utfc_ptr2len(path_end));
|
||||||
|
@ -6,16 +6,19 @@ local command = helpers.command
|
|||||||
local insert = helpers.insert
|
local insert = helpers.insert
|
||||||
local feed = helpers.feed
|
local feed = helpers.feed
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
local rmdir = helpers.rmdir
|
||||||
|
local write_file = helpers.write_file
|
||||||
|
|
||||||
|
local function join_path(...)
|
||||||
|
local pathsep = (is_os('win') and '\\' or '/')
|
||||||
|
return table.concat({...}, pathsep)
|
||||||
|
end
|
||||||
|
|
||||||
describe('path collapse', function()
|
describe('path collapse', function()
|
||||||
local targetdir
|
local targetdir
|
||||||
local expected_path
|
local expected_path
|
||||||
|
|
||||||
local function join_path(...)
|
|
||||||
local pathsep = (is_os('win') and '\\' or '/')
|
|
||||||
return table.concat({...}, pathsep)
|
|
||||||
end
|
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
targetdir = join_path('test', 'functional', 'fixtures')
|
targetdir = join_path('test', 'functional', 'fixtures')
|
||||||
clear()
|
clear()
|
||||||
@ -57,6 +60,27 @@ describe('path collapse', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('expand wildcard', function()
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
|
it('with special characters #24421', function()
|
||||||
|
local folders = is_os('win') and {
|
||||||
|
'{folder}',
|
||||||
|
'folder$name'
|
||||||
|
} or {
|
||||||
|
'folder-name',
|
||||||
|
'folder#name'
|
||||||
|
}
|
||||||
|
for _, folder in ipairs(folders) do
|
||||||
|
mkdir(folder)
|
||||||
|
local file = join_path(folder, 'file.txt')
|
||||||
|
write_file(file, '')
|
||||||
|
eq(file, eval('expand("'..folder..'/*")'))
|
||||||
|
rmdir(folder)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
describe('file search', function()
|
describe('file search', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user