mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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>
This commit is contained in:
parent
a4aa97590b
commit
8e25d91cb7
4
runtime/autoload/dist/vim.vim
vendored
4
runtime/autoload/dist/vim.vim
vendored
@ -18,6 +18,10 @@ endif
|
|||||||
if !has('vim9script')
|
if !has('vim9script')
|
||||||
function dist#vim#IsSafeExecutable(filetype, executable)
|
function dist#vim#IsSafeExecutable(filetype, executable)
|
||||||
let cwd = getcwd()
|
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)) &&
|
return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) &&
|
||||||
\ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
|
\ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
|
||||||
\ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&
|
\ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&
|
||||||
|
4
runtime/autoload/dist/vim9.vim
vendored
4
runtime/autoload/dist/vim9.vim
vendored
@ -6,6 +6,10 @@ vim9script
|
|||||||
# Last Change: 2023 Oct 25
|
# Last Change: 2023 Oct 25
|
||||||
|
|
||||||
export def IsSafeExecutable(filetype: string, executable: string): bool
|
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()
|
var cwd = getcwd()
|
||||||
return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
|
return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
|
||||||
&& (fnamemodify(exepath(executable), ':p:h') !=# cwd
|
&& (fnamemodify(exepath(executable), ':p:h') !=# cwd
|
||||||
|
Loading…
x
Reference in New Issue
Block a user