To: vim_dev@googlegroups.com Subject: Patch 8.2.3219 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3219 Problem: :find searches non-existing directories. Solution: Check the path is not "..". Update help. (Christian Brabandt, closes #8612, closes #8533) Files: runtime/doc/editing.txt, src/findfile.c, src/testdir/test_findfile.vim *** ../vim-8.2.3218/runtime/doc/editing.txt 2021-01-31 17:02:06.246490203 +0100 --- runtime/doc/editing.txt 2021-07-25 15:02:24.242119813 +0200 *************** *** 1749,1754 **** --- 1752,1763 ---- /u/user_x/work/include /u/user_x/include + < Note: If your 'path' setting includes an non-existing directory, Vim will + skip the non-existing directory, but continues searching in the parent of + the non-existing directory if upwards searching is used. E.g. when + searching "../include" and that doesn't exist, and upward searching is + used, also searches in "..". + 3) Combined up/downward search: If Vim's current path is /u/user_x/work/release and you do > set path=**;/u/user_x *** ../vim-8.2.3218/src/findfile.c 2021-06-06 14:14:35.348774346 +0200 --- src/findfile.c 2021-07-25 15:07:03.273462128 +0200 *************** *** 578,584 **** --- 578,593 ---- 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); } *** ../vim-8.2.3218/src/testdir/test_findfile.vim 2020-08-12 18:50:31.875655822 +0200 --- src/testdir/test_findfile.vim 2021-07-25 14:56:59.922845141 +0200 *************** *** 228,231 **** --- 228,253 ---- 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 *** ../vim-8.2.3218/src/version.c 2021-07-25 14:36:01.569551193 +0200 --- src/version.c 2021-07-25 15:07:23.657412208 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3219, /**/ -- hundred-and-one symptoms of being an internet addict: 234. You started college as a chemistry major, and walk out four years later as an Internet provider. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///