svn path=/trunk/; revision=33
# You should have received a copy of the GNU Affero General Public License
# along with shcgi. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU Affero General Public License
# along with shcgi. If not, see <http://www.gnu.org/licenses/>.
+unset _GET _POST _REF _COOKIE
declare -A _GET
declare -A _POST
declare -A _REF
declare -A _GET
declare -A _POST
declare -A _REF
debug "_GET[$key] => $val"
done
debug "_GET[$key] => $val"
done
-if [ "$REQUEST_METHOD" = POST ]; then
+if [ "$REQUEST_METHOD" = POST -a "$HTTP_CONTENT_LENGTH" -gt 0 ]; then
# parse HTTP POST string
debug "== CGI DATA: POST =="
# parse HTTP POST string
debug "== CGI DATA: POST =="
- sed -u 1q |tr '&' '\n' |while read query; do
+ head -c "$HTTP_CONTENT_LENGTH" \
+ | sed -un '2q; 1{s;&;\n;g; p}' \
+ | 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:')"
value="$(printf "$(printf %s "$val" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g;')")"
key="$(printf %s "$query" |sed -r 's:^([\.a-zA-Z0-9_-]+)=(.*)$:\1:')"
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;')")"