X-Git-Url: http://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=cgilite.sh;h=7eab08a5b4bc92691b34e7cdc3e61679f2f8d2b6;hp=e0d4b9392cda8709e80509b176961957ce0008ca;hb=e2678dc719c2dcda2de9a6079ac63837681e1a26;hpb=1f1b81d3613914df56b3502aa79896ca2d9ca551 diff --git a/cgilite.sh b/cgilite.sh index e0d4b93..7eab08a 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -49,7 +49,7 @@ HEX_DECODE=' ' HEX_DECODE(){ - printf "$(printf %s "$1" |sed -r "$HEX_DECODE")" + printf -- "$(printf %s "$1" |sed -r "$HEX_DECODE")" } if [ -z "$REQUEST_METHOD" ]; then @@ -92,7 +92,7 @@ if [ -z "$REQUEST_METHOD" ]; then "$cgilite_response" "${cgilite_cl}" cat [ "${cgilite_cl#Connection}" = "${cgilite_cl}" ]; exit;; - *) cgilite_response="$cgilite_response${BR}$l";; + *) cgilite_response="${cgilite_response:+${cgilite_response}${BR}}${l}";; esac; done || exit 0; (sleep $cgilite_timeout && kill $$) & cgilite_watchdog=$! done @@ -116,17 +116,29 @@ cgilite_value(){ str=${str#*&${name}=} cnt=$((cnt - 1)) done - printf "$(printf %s "${str%%&*}" |sed -r 's;\+; ;g;'"$HEX_DECODE")" + printf -- "$(printf %s "${str%%&*}" |sed -r 's;\+; ;g;'"$HEX_DECODE")" +} + +cgilite_keys(){ + local str="&$1" + while [ "${str#*&}" != "${str}" ]; do + str="${str#*&}" + printf '%s\n' "${str%%=*}" + done \ + | sort -u } GET(){ cgilite_value "${QUERY_STRING}" $@; } GET_COUNT(){ cgilite_count "${QUERY_STRING}" $1; } +GET_KEYS(){ cgilite_keys "${QUERY_STRING}"; } POST(){ cgilite_value "${cgilite_post}" $@; } POST_COUNT(){ cgilite_count "${cgilite_post}" $1; } +POST_KEYS(){ cgilite_keys "${cgilite_post}"; } REF(){ cgilite_value "${HTTP_REFERER#*\?}" $@; } REF_COUNT(){ cgilite_count "${HTTP_REFERER#*\?}" $1; } +REF_KEYS(){ cgilite_keys "${HTTP_REFERER#*\?}"; } COOKIE(){ HEX_DECODE "$(