]> git.plutz.net Git - cgilite/blobdiff - cgilite.sh
bugfix: do not expect query strings to start with "?"
[cgilite] / cgilite.sh
index c00f9e7cd930674b052e3af1d49b1ebc68562cb7..e2634240970031582aa096157702213fd6752118 100755 (executable)
@@ -28,22 +28,22 @@ fi
 
 cgilite_count(){
   case $1 in
-    GET)  printf %s "${QUERY_STRING}";;
-    POST) printf %s "?${cgilite_post}";;
-    REF)  printf %s "?${HTTP_REFERER#*\?}";;
+    GET)  printf %s "&${QUERY_STRING}";;
+    POST) printf %s "&${cgilite_post}";;
+    REF)  printf %s "&${HTTP_REFERER#*\?}";;
   esac \
-  | grep -Eo '[&?]'"$2"'=[^&]*' \
+  | grep -Eo '&'"$2"'=[^&]*' \
   | wc -l
 }
 
 cgilite_value(){
   printf "$(
     case $1 in
-      GET)  printf %s "${QUERY_STRING}";;
-      POST) printf %s "?${cgilite_post}";;
-      REF)  printf %s "?${HTTP_REFERER#*\?}";;
+      GET)  printf %s "&${QUERY_STRING}";;
+      POST) printf %s "&${cgilite_post}";;
+      REF)  printf %s "&${HTTP_REFERER#*\?}";;
     esac \
-    | grep -Eo '[&?]'"$2"'=[^&]*' \
+    | grep -Eo '&'"$2"'=[^&]*' \
     | sed -rn "${3:-1}"'{s;^[^=]+=;;; s;\+; ;g; s;\\;\\\\;g; s;%;\\x;g; p}'
   )"
 }
@@ -111,6 +111,6 @@ SET_COOKIE(){
 }
 
 REDIRECT(){
-  printf 'Location: %s\r\n\r\n' "$*"
+  printf '%s 303 See Other\r\nLocation: %s\r\n\r\n' "$SERVER_PROTOCOL" "$*"
   exit 0
 }