mirror of
https://github.com/neovim/neovim.git
synced 2026-07-31 04:39:07 +00:00
fix(path): DOS device path check #40976
Problem: The current check is intended to match DOS device paths starting with `\\?` or `\\.` but will match any path starting with `?` or `.`, including relative paths such as `.\`. This is because the leading slashes are removed before the comparison. Solution: Changes the check to include the path's prefix, assuring the path has the correct amount of separators for a DOS device path.
This commit is contained in:
committed by
GitHub
parent
dec3d8215d
commit
4a5062cda6
@@ -1227,7 +1227,7 @@ bool os_fileinfo2(const char *path, FileInfo *info)
|
||||
info->rest_off = (size_t)(p - path);
|
||||
return true;
|
||||
}
|
||||
if (p[0] == '?' || p[0] == '.') {
|
||||
if (leading_slashes >= 2 && (p[0] == '?' || p[0] == '.')) {
|
||||
if (!vim_ispathsep_nocolon(p[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -182,6 +182,11 @@ describe('fnamemodify()', function()
|
||||
eq('//?/UNC/server', fnamemodify('//?/UNC/server', ':h'))
|
||||
eq('//?/UNC/server/share', fnamemodify('//?/UNC/server/share', ':h'))
|
||||
eq('//?/UNC/server/share/', fnamemodify('//?/UNC/server/share/foo', ':h'))
|
||||
|
||||
-- relative "./" and ".\" prefixes
|
||||
eq('./path/to', fnamemodify('./path/to/hello.txt', ':h'))
|
||||
eq('./path', fnamemodify('./path/to/hello.txt', ':h:h'))
|
||||
eq('./path/to', fnamemodify([[.\path\to\hello.txt]], ':h'))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user