Skip to content

Commit 8e25d91

Browse files
committed
runtime(dist): verify that executable is in $PATH
Otherwise, if the executable to be verified does not exist, this would cause a false-positive in the 'IsSafeExecutable()' check, because 'exepath(executable)' returns an empty string and 'fnamemodify('', ':p:h')' returns the current directory and as a result the 'IsSafeExecutable()' returns false (for the wrong reason). Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent a4aa975 commit 8e25d91

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

runtime/autoload/dist/vim.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ endif
1818
if !has('vim9script')
1919
function dist#vim#IsSafeExecutable(filetype, executable)
2020
let cwd = getcwd()
21+
if empty(exepath(a:executable))
22+
echomsg a:executable .. " not found in $PATH"
23+
return v:false
24+
endif
2125
return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) &&
2226
\ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
2327
\ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&

runtime/autoload/dist/vim9.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ vim9script
66
# Last Change: 2023 Oct 25
77

88
export def IsSafeExecutable(filetype: string, executable: string): bool
9+
if empty(exepath(executable))
10+
echomsg executable .. " not found in $PATH"
11+
return v:false
12+
endif
913
var cwd = getcwd()
1014
return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
1115
&& (fnamemodify(exepath(executable), ':p:h') !=# cwd

0 commit comments

Comments
 (0)