kiss: disallow newlines in arguments

This commit is contained in:
Dylan Araps 2021-07-19 11:49:38 +03:00
parent 75295c11e8
commit 8ead0b1096
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C
1 changed files with 13 additions and 11 deletions

24
kiss
View File

@ -225,8 +225,9 @@ sh256() {
esac; shift; done esac; shift; done
printf '%s\n' "$@" printf '%s\n' "$@"
IFS="$newline"
hash=$* # Convert the list items to a newline separated string.
IFS=$newline hash=$*
unset IFS unset IFS
} }
@ -1647,25 +1648,26 @@ args() {
# not be used here as they would conflict with kiss extensions. # not be used here as they would conflict with kiss extensions.
case $action in case $action in
a|alternatives) a|alternatives)
case $1 in *\**|*\!*|*\[*|*\ *|*\]*|*/*) case $1 in *\**|*\!*|*\[*|*\ *|*\]*|*/*|*"$newline"*)
die "Invalid argument: '!*[ ]/' ($1)" die "Invalid argument: '!*[ ]/\\n' ($1)"
esac esac
;; ;;
b|build|c|checksum|d|download|i|install|l|list|r|remove) b|build|c|checksum|d|download|i|install|l|list|r|remove)
for _arg do case ${action%%"${action#?}"}-$_arg in for _arg do case ${action%%"${action#?}"}-$_arg in
i-*\!*|i-*\**|i-*\[*|i-*\ *|i-*\]*) i-*\!*|i-*\**|i-*\[*|i-*\ *|i-*\]*|i-*"$newline"*)
die "Argument contains invalid characters: '!*[ ]' ('$_arg')" die "Invalid argument: '!*[ ]\\n' ('$_arg')"
;; ;;
[!i]-*\!*|[!i]-*\**|[!i]-*\[*|[!i]-*\ *|[!i]-*\]*|[!i]-*/*) [!i]-*\!*|[!i]-*\**|[!i]-*\[*|[!i]-*\ *|\
die "Argument contains invalid characters: '!*[ ]/' ('$_arg')" [!i]-*\]*|[!i]-*/*|[!i]-*"$newline"*)
die "Invalid argument: '!*[ ]/\\n' ('$_arg')"
;; ;;
esac done esac done
# When no arguments are given on the command-line, use the basename of # When no arguments are given on the command-line, use the basename
# the current directory as the package name and add the parent directory # of the current directory as the package name and add the parent
# to the running process' KISS_PATH. # directory to the running process' KISS_PATH.
case ${action%%"${action#?}"}-$# in [!l]-0) case ${action%%"${action#?}"}-$# in [!l]-0)
export KISS_PATH=${PWD%/*}:$KISS_PATH export KISS_PATH=${PWD%/*}:$KISS_PATH
set -- "${PWD##*/}" set -- "${PWD##*/}"