Improve reading of post data on l-b-cgi frontend.
authorRichard Nelson <unixabg@gmail.com>
Thu, 23 May 2013 13:07:35 +0000 (08:07 -0500)
committerDaniel Baumann <mail@daniel-baumann.ch>
Mon, 27 May 2013 15:13:56 +0000 (17:13 +0200)
frontends/cgi/live-build-cgi

index 5a65bce..dbc1ef5 100755 (executable)
@@ -33,9 +33,15 @@ echo "Content-type: text/html"
 echo
 
 #QUERY_STRING=`cat /dev/stdin`
-QUERY_STRING=$(cat /dev/stdin)
+#QUERY_STRING=$(cat /dev/stdin)
+# If we are passed something then read it in.
+if [[ "$REQUEST_METHOD" = "POST" ]] && [[ "$CONTENT_LENGTH" -gt 0 ]]
+then
+       read -n $CONTENT_LENGTH POST_DATA <&0
+fi
+
 # Translate parameters
-QUERY_STRING=$(echo "${QUERY_STRING}" | sed -e 's/%2F/\//g' -e 's/+/ /g' -e 's/%3B/;/g' -e 's/%7E/~/g' -e 's/%3A/:/g' -e 's/%40/@/g' -e 's/%3D/=/g' -e 's/%2B/+/g')
+QUERY_STRING=$(echo "${POST_DATA}" | sed -e 's/%2F/\//g' -e 's/+/ /g' -e 's/%3B/;/g' -e 's/%7E/~/g' -e 's/%3A/:/g' -e 's/%40/@/g' -e 's/%3D/=/g' -e 's/%2B/+/g')
 # Debug the filtering string
 # echo ${QUERY_STRING}