]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(dist): verify that executable is in $PATH
authorChristian Brabandt <cb@256bit.org>
Sat, 17 Aug 2024 13:52:11 +0000 (15:52 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 17 Aug 2024 19:00:55 +0000 (21:00 +0200)
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>
runtime/autoload/dist/vim.vim
runtime/autoload/dist/vim9.vim

index 021244c93b3fa5668a8c55c177d5f7ca9ef21839..d51940653000cc9538bbbcacaa839e788e6a80b7 100644 (file)
@@ -18,6 +18,10 @@ endif
 if !has('vim9script')
   function dist#vim#IsSafeExecutable(filetype, executable)
     let cwd = getcwd()
+    if empty(exepath(a:executable))
+      echomsg a:executable .. " not found in $PATH"
+      return v:false
+    endif
     return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) &&
           \ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
           \ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&
index 807140da7ca06b714f928c9351338b5fa4b6b234..8fa9380f5774f53838ced5266c6561f73a6bdad5 100644 (file)
@@ -6,6 +6,10 @@ vim9script
 # Last Change: 2023 Oct 25
 
 export def IsSafeExecutable(filetype: string, executable: string): bool
+    if empty(exepath(executable))
+      echomsg executable .. " not found in $PATH"
+      return v:false
+    endif
     var cwd = getcwd()
     return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
       && (fnamemodify(exepath(executable), ':p:h') !=# cwd