patch 8.2.3219: :find searches non-existing directories
Problem: :find searches non-existing directories.
Solution: Check the path is not "..". Update help. (Christian Brabandt,
closes #8612, closes #8533)
diff --git a/src/findfile.c b/src/findfile.c
index a72fe45..7c2a61f 100644
--- a/src/findfile.c
+++ b/src/findfile.c
@@ -578,7 +578,16 @@
if (p > search_ctx->ffsc_fix_path)
{
+ // do not add '..' to the path and start upwards searching
len = (int)(p - search_ctx->ffsc_fix_path) - 1;
+ if ((len >= 2
+ && STRNCMP(search_ctx->ffsc_fix_path, "..", 2) == 0)
+ && (len == 2
+ || search_ctx->ffsc_fix_path[2] == PATHSEP))
+ {
+ vim_free(buf);
+ goto error_return;
+ }
STRNCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, len);
add_pathsep(ff_expand_buffer);
}
diff --git a/src/testdir/test_findfile.vim b/src/testdir/test_findfile.vim
index 188851f..017089e 100644
--- a/src/testdir/test_findfile.vim
+++ b/src/testdir/test_findfile.vim
@@ -228,4 +228,26 @@
call assert_fails('tabfind', 'E471:')
endfunc
+func Test_find_non_existing_path()
+ new
+ let save_path = &path
+ let save_dir = getcwd()
+ call mkdir('dir1/dir2', 'p')
+ call writefile([], 'dir1/file.txt')
+ call writefile([], 'dir1/dir2/base.txt')
+ call chdir('dir1/dir2')
+ e base.txt
+ set path=../include
+
+ call assert_fails(':find file.txt', 'E345:')
+
+ call chdir(save_dir)
+ bw!
+ call delete('dir1/dir2/base.txt', 'rf')
+ call delete('dir1/dir2', 'rf')
+ call delete('dir1/file.txt', 'rf')
+ call delete('dir1', 'rf')
+ let &path = save_path
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 9b334e6..ac5989f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3219,
+/**/
3218,
/**/
3217,