]> git.plutz.net Git - cgilite/blobdiff - cgi.sh
account for Different CGI variable naming in apache
[cgilite] / cgi.sh
diff --git a/cgi.sh b/cgi.sh
index 7b5651af6eec81d3f9720bfd9227b03ac626960e..c366843f8609ab5fd9640e698e359df7258ee50a 100755 (executable)
--- a/cgi.sh
+++ b/cgi.sh
@@ -34,17 +34,11 @@ printf '%s\n' "$QUERY_STRING" |tr '&' '\n' |while read query; do
   debug "_GET[$key] => $val"
 done
 
-if [ "$REQUEST_METHOD" = POST -a "$HTTP_CONTENT_LENGTH" -gt 0 ]; then
+if [ "$REQUEST_METHOD" = POST -a "${HTTP_CONTENT_LENGTH:=$CONTENT_LENGTH}" -gt 0 ]; then
   # parse HTTP POST string
   debug "== CGI DATA: POST =="
   head -c "$HTTP_CONTENT_LENGTH" \
-  | sed -un '
-    2q
-    1{
-      s;&;\n;g;
-      a
-      p
-    }' \
+  | sed -un 's;&;\n;g; p; q' \
   | while read query; do
     key="$(printf %s "$query" |sed -r 's:^([\.a-zA-Z0-9_-]+)=(.*)$:\1:')"
     val="$(printf %s "$query" |sed -r 's:^([\.a-zA-Z0-9_-]+)=(.*)$:\2:')"