Skip to content
Myr

[completion] Prevent running a command during 'eval'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Do not attempt to provide fuzzy completion if the prefix contains a pattern that may start an arbitraty command. * $(...) * `...` * <(...) Close #3459

authored by Junegunn Choi · committed by Junegunn Choi · parent 4fdc082 · Browse files · 2 files+8 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−2 removed

  • other:+8 added−2 removed

2 files+8 added−2 removed

modified:shell/completion.bash+2 added-2 removed
168 unmodified lines
169 cmd="${cmd//[^A-Za-z0-9_=]/_}"170 COMPREPLY=()171 trigger=${FZF_COMPLETION_TRIGGER-'**'}172 cur="${COMP_WORDS[COMP_CWORD]}"173 if [[ "$cur" == *"$trigger" ]]; then173 if [[ "$cur" == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *'<('* ]] && [[ $cur != *'`'* ]]; then174 base=${cur:0:${#cur}-${#trigger}}175 eval "base=$base"176177 dir=
56 unmodified lines
234235 cmd="${COMP_WORDS[0]//[^A-Za-z0-9_=]/_}"236 trigger=${FZF_COMPLETION_TRIGGER-'**'}237 cur="${COMP_WORDS[COMP_CWORD]}"238 if [[ "$cur" == *"$trigger" ]]; then238 if [[ "$cur" == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *'<('* ]] && [[ $cur != *'`'* ]]; then239 cur=${cur:0:${#cur}-${#trigger}}240241 selected=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-} $str_arg" __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | $post | tr '\n' ' ')242 selected=${selected% } # Strip trailing space not to repeat "-o nospace"
163 unmodified lines
modified:shell/completion.zsh+6 added
135 unmodified lines
136 suffix=$5137 tail=$6138139 setopt localoptions nonomatch140 if [[ $base = *'$('* ]] || [[ $base = *'<('* ]] || [[ $base = *'`'* ]]; then141 return142 fi143 eval "base=$base"144 [[ $base = *"/"* ]] && dir="$base"145 while [ 1 ]; do146 if [[ -z "$dir" || -d ${dir} ]]; then
159 unmodified lines
306 if [ ${#tokens} -gt 1 -a "$tail" = "$trigger" ]; then307 d_cmds=(${=FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir})308309 [ -z "$trigger" ] && prefix=${tokens[-1]} || prefix=${tokens[-1]:0:-${#trigger}}310 if [[ $prefix = *'$('* ]] || [[ $prefix = *'<('* ]] || [[ $prefix = *'`'* ]]; then311 return312 fi313 [ -n "${tokens[-1]}" ] && lbuf=${lbuf:0:-${#tokens[-1]}}314315 if eval "type _fzf_complete_${cmd} > /dev/null"; then316 prefix="$prefix" eval _fzf_complete_${cmd} ${(q)lbuf}
26 unmodified lines