1
0
forked from aniani/vim

patch 9.1.0569: fnamemodify() treats ".." and "../" differently

Problem:  fnamemodify() treats ".." and "../" differently.
Solution: Expand ".." properly like how "/.." is treated in 8.2.3388.
          (zeertzjq)

closes: #15218

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-07-12 07:29:14 +02:00
committed by Christian Brabandt
parent fc533c9f06
commit 1ee7420460
5 changed files with 30 additions and 4 deletions

View File

@@ -2699,6 +2699,9 @@ mch_FullName(
if ((force || !mch_isFullName(fname))
&& ((p = vim_strrchr(fname, '/')) == NULL || p != fname))
{
if (p == NULL && STRCMP(fname, "..") == 0)
// Handle ".." without path separators.
p = fname + 2;
/*
* If the file name has a path, change to that directory for a moment,
* and then get the directory (and get back to where we were).
@@ -2707,7 +2710,7 @@ mch_FullName(
if (p != NULL)
{
if (STRCMP(p, "/..") == 0)
// for "/path/dir/.." include the "/.."
// For "/path/dir/.." include the "/..".
p += 3;
#ifdef HAVE_FCHDIR