# Store fields from a HTTP GET or POST string in a file
# usage: STORE "${QUERY_STRING}"
# or: STORE "$(head -n $HTTP_CONTENT_LENGTH)"
+ # backslashes and newline characters will be escaped in field values,
+ # the escape symbol is a backslash
+ # hexadecimal character descriptions (%00 - %FF) will be expanded
+ # the + character will be converted to [space]
+ # one line in the output corresponds to exactly one field, so you can
+ # use grep to filter which fields of a query should be stored
printf "$(
- printf '&%s' "$@" \
+ printf '%s' "$@" \
| sed -r ':X; $bY; N; bX; :Y;
s;\+; ;g; s;(\\|5[Cc]);\\\\\\\\;g; s;(\n|%0[Aa]);\\\\n;g; s;(^|&)([^=]+)=;\1\2:;g; s;&;\n;g;
s;^\n+;;; s;$;\\n;; s;\n+;\n;g;