From: paul Date: Sat, 27 Feb 2016 16:13:13 +0000 (+0000) Subject: allow empty fields in POST data X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=7baad0fc1db205353fe7414d358b43a015ef5848;p=shcgi allow empty fields in POST data svn path=/trunk/; revision=21 --- diff --git a/cgi.sh b/cgi.sh index 124496e..2a6c930 100755 --- a/cgi.sh +++ b/cgi.sh @@ -41,9 +41,9 @@ if [ "$REQUEST_METHOD" = POST ]; then val="$(printf %s "$query" |sed -r 's:^([a-zA-Z0-9_-]+)=(.*)$:\2:')" value="$(printf "$(printf %s "$val" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g;')")" n='' - if [ -n "${_POST[$key$n]}" ]; then + if [ -n "${_POST[$key$n]+x}" ]; then n=0 - while [ -n "${_POST[$key$n]}" ]; do n=$(($n + 1)); done + while [ -n "${_POST[$key$n]+x}" ]; do n=$(($n + 1)); done fi _POST[$key$n]="$value" debug "_POST[$key$n] => $value" diff --git a/misc.sh b/misc.sh index ee4eaaf..adc879b 100755 --- a/misc.sh +++ b/misc.sh @@ -53,5 +53,5 @@ invalidate(){ declare -A item_name l10n(){ - [ -n "$item_name[$1]" ] && printf %s "$item_name[$1]" || printf %s "$1" + [ -n "$item_name[$1]+x" ] && printf %s "$item_name[$1]" || printf %s "$1" }