X-Git-Url: http://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=cgilite.sh;h=3212137e68bcb262b338256d29b29d952c3ca9d1;hp=996fe9daa4befceac6e7461b7e4755e03feebe9c;hb=2509a90ca35ffada128256670abf1d5c315ef6ce;hpb=fcb3e2096bd811a910c686bbfe181708878ba8b4 diff --git a/cgilite.sh b/cgilite.sh index 996fe9d..3212137 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -22,8 +22,9 @@ # set -o posix # ksh, not portable setopt -o OCTAL_ZEROES 2>&- -BR="$(printf '\n')" -CR="$(printf '\r')" +CR=" " +BR=' +' cgilite_timeout=2 HEADER(){ @@ -48,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 @@ -70,7 +71,7 @@ if [ -z "$REQUEST_METHOD" ]; then kill $cgilite_watchdog PATH_INFO="$(HEX_DECODE "${REQUEST_URI%\?*}")" QUERY_STRING="${REQUEST_URI#*\?}" - cgilite_headers="$(sed -u '/^\r\?$/q')" + cgilite_headers="$(while read -r hl; do [ "${hl%${CR}}" ] && printf '%s\n' "$hl" || break; done )" HTTP_CONTENT_LENGTH="$(HEADER Content-Length |grep -xE '[0-9]+')" @@ -115,7 +116,7 @@ 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")" } GET(){ cgilite_value "${QUERY_STRING}" $@; }