allow empty fields in POST data
authorpaul <paul@plutz.net>
Sat, 27 Feb 2016 16:13:13 +0000 (16:13 +0000)
committerpaul <paul@plutz.net>
Sat, 27 Feb 2016 16:13:13 +0000 (16:13 +0000)
svn path=/trunk/; revision=21

cgi.sh
misc.sh

diff --git a/cgi.sh b/cgi.sh
index 124496e..2a6c930 100755 (executable)
--- 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 (executable)
--- 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"
 }