Skip to content

Commit

Permalink
fix(mutt): use _comp_dequote for safe eval
Browse files Browse the repository at this point in the history
In addition, `eval` can be applied to only the content of `spoolfile`,
which was originally extracted from the mutt output of the form
`spoolfile="..."`.  After expanding the escape sequences in
$spoolfile, we combine it with `cur`.
  • Loading branch information
akinomyoga committed Dec 24, 2023
1 parent 63924e6 commit f98379d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion completions/mutt
Expand Up @@ -136,7 +136,10 @@ _comp_cmd_mutt__filedir()
elif [[ $cur == !* ]]; then
spoolfile="$("$muttcmd" -F "$muttrc" -Q spoolfile 2>/dev/null |
command sed -e 's|^spoolfile=\"\(.*\)\"$|\1|')"
[[ $spoolfile ]] && eval cur="${cur/#!/$spoolfile}"
if [[ $spoolfile ]]; then
_comp_dequote "\"$spoolfile\"" && spoolfile=$REPLY
cur="${cur/#!/$spoolfile}"
fi
fi
_comp_compgen -c "$cur" filedir
}
Expand Down

0 comments on commit f98379d

Please sign in to comment.