X-Git-Url: http://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=files.sh;h=bf8b7b9f44343d3c210c57800b5e606208f6e6b2;hp=6c459c524d615105c89c8457abb58a6249696b9f;hb=147a3ae4c390dfc186f25b0aba267d7ff23b2151;hpb=f53f3103ded9696b19666f32620642172ffa9c09 diff --git a/files.sh b/files.sh index 6c459c5..bf8b7b9 100755 --- a/files.sh +++ b/files.sh @@ -27,8 +27,14 @@ STORE(){ # 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;