Clear unwanted environment variable

This adds two things I forgot in
9a7d8df4 (Avoid accidentally using environment variables in sh scopes)

Mea culpa, the problem was that I was skipping matches with "filetype"
because that's usually just a hook parameter as in "WinSetOption filetype=.."

	rg --pcre2 '\b(?!filetype=)\w+=' rc/

So I missed these two cases where a shell variable is actually called "filetype".

The one in git.kak was not a problem because show_git_cmd_output is only
ever called with sane inputs.  However, file.kak does use the filetype
environment variable for many mime types, for example:

	filetype=somefiletype\''; echo -debug injection; nop '\' kak /dev/null

Will run the echo since /dev/null has mime type "inode/chardevice"
This commit is contained in:
Johannes Altmanninger 2020-09-01 21:38:04 +02:00
parent e0d2602e6a
commit 407c72d90a
2 changed files with 2 additions and 0 deletions

View File

@ -12,6 +12,7 @@ hook global BufOpenFile .* %{ evaluate-commands %sh{
text/*) filetype="${mime#text/}" ;;
application/x-*) filetype="${mime#application/x-}" ;;
application/*) filetype="${mime#application/}" ;;
*) exit ;;
esac
if [ -n "${filetype}" ]; then
printf "set-option buffer filetype '%s'\n" "${filetype}"

View File

@ -78,6 +78,7 @@ define-command -params 1.. \
diff) filetype=diff ;;
log|show) filetype=git-log ;;
status) filetype=git-status ;;
*) return 1 ;;
esac
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo
mkfifo ${output}