m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-16 23:33:39 -05:00

[completion] Prevent running a command during 'eval'

Do not attempt to provide fuzzy completion if the prefix contains a
pattern that may start an arbitraty command.

* $(...)
* `...`
* <(...)

Close #3459
This commit is contained in:
Junegunn Choi
2023-10-02 20:40:49 +09:00
parent 4fdc08295b
commit ee4ba104e7
2 changed files with 8 additions and 2 deletions

View File

@@ -137,6 +137,9 @@ __fzf_generic_path_completion() {
tail=$6
setopt localoptions nonomatch
if [[ $base = *'$('* ]] || [[ $base = *'<('* ]] || [[ $base = *'`'* ]]; then
return
fi
eval "base=$base"
[[ $base = *"/"* ]] && dir="$base"
while [ 1 ]; do
@@ -304,6 +307,9 @@ fzf-completion() {
d_cmds=(${=FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir})
[ -z "$trigger" ] && prefix=${tokens[-1]} || prefix=${tokens[-1]:0:-${#trigger}}
if [[ $prefix = *'$('* ]] || [[ $prefix = *'<('* ]] || [[ $prefix = *'`'* ]]; then
return
fi
[ -n "${tokens[-1]}" ] && lbuf=${lbuf:0:-${#tokens[-1]}}
if eval "type _fzf_complete_${cmd} > /dev/null"; then