From 4a5062cda69fa6cb59b7dc0c488dfb05accf99de Mon Sep 17 00:00:00 2001 From: Dominic Della Valle Date: Sun, 26 Jul 2026 07:18:57 -0400 Subject: 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. --- test/functional/vimscript/fnamemodify_spec.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/fnamemodify_spec.lua b/test/functional/vimscript/fnamemodify_spec.lua index 65a1ec72e9..c9b93dd31d 100644 --- a/test/functional/vimscript/fnamemodify_spec.lua +++ b/test/functional/vimscript/fnamemodify_spec.lua @@ -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) -- cgit