From: paul Date: Thu, 7 Apr 2016 01:23:06 +0000 (+0000) Subject: allow dot in parameter keys X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=397e40b92e591ae9066dcabb414d8097555beea8;p=cgilite allow dot in parameter keys svn path=/trunk/; revision=23 --- diff --git a/cgi.sh b/cgi.sh index 2a6c930..408201f 100755 --- a/cgi.sh +++ b/cgi.sh @@ -27,8 +27,8 @@ declare -A _COOKIE # parse HTTP GET string debug "== CGI DATA: GET ==" printf '%s\n' "$QUERY_STRING" |tr '&' '\n' |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:')" + key="$(printf %s "$query" |sed -r 's:^([\.a-zA-Z0-9_-]+)=(.*)$:\1:')" + val="$(printf %s "$query" |sed -r 's:^([\.a-zA-Z0-9_-]+)=(.*)$:\2:')" _GET[$key]="$(printf "$(printf %s "$val" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g')")" debug "_GET[$key] => $val" done @@ -37,8 +37,8 @@ if [ "$REQUEST_METHOD" = POST ]; then # parse HTTP POST string debug "== CGI DATA: POST ==" sed -u 1q |tr '&' '\n' |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:')" + 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;')")" n='' if [ -n "${_POST[$key$n]+x}" ]; then @@ -53,8 +53,8 @@ fi cgi_refdata() { # Parse GET data from referer debug "== CGI DATA: REFERER ==" printf '%s\n' "${HTTP_REFERER#*\?}" |tr '&' '\n' |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:')" + key="$(printf %s "$query" |sed -r 's:^([\.a-zA-Z0-9_-]+)=(.*)$:\1:')" + val="$(printf %s "$query" |sed -r 's:^([\.a-zA-Z0-9_-]+)=(.*)$:\2:')" _REF[$key]="$(printf "$(printf %s "$val" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g')")" debug "_REF[$key] => $val" done @@ -63,8 +63,8 @@ cgi_refdata() { # Parse GET data from referer cgi_cookie() { # Parse GET data from referer debug "== CGI DATA: COOKIE ==" printf '%s\n' "$HTTP_COOKIE" |tr ';' '\n' |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:')" + key="$(printf %s "$query" |sed -r 's:^ *([\.a-zA-Z0-9_-]+)=(.*)$:\1:')" + val="$(printf %s "$query" |sed -r 's:^ *([\.a-zA-Z0-9_-]+)=(.*)$:\2:')" _COOKIE[$key]="$(printf "$(printf %s "$val" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g')")" debug "_COOKIE[$key] => $val" done