]> git.plutz.net Git - cgilite/blobdiff - cgilite.sh
fix: task list unsure
[cgilite] / cgilite.sh
index 7af962332cde39d1a4f0583da271159f8281f475..23f5a1cf98fb8d5327fd9317b11edecc04bc4e76 100755 (executable)
@@ -85,8 +85,14 @@ HEX_DECODE(){
   # will be copied to the output literally
 
   while [ "$in" ]; do
+    [ "$pfx" ] || case $in in
+      [0-9a-fA-F][0-9a-fA-F]*):;;
+      ?*) out="${out}${in%%"${in#?}"}"
+          in="${in#?}"; continue;;
+    esac
+
     case $in in
-      "$pfx"[0-9a-fA-F][0-9a-fA-F]*) in="${in#${pfx}}";;
+      "$pfx"[0-9a-fA-F][0-9a-fA-F]*) in="${in#"${pfx}"}";;
       \\*) in="${in#?}"; out="${out}\\\\"; continue;;
        %*) in="${in#?}"; out="${out}%%";  continue;;
         *) att="${in%%"${pfx}"*}"; att="${att%%%*}"; att="${att%%\\*}"
@@ -164,7 +170,7 @@ if [ -z "$REQUEST_METHOD" ]; then
     done
 
     export REMOTE_ADDR SERVER_NAME SERVER_PORT REQUEST_METHOD REQUEST_URI SERVER_PROTOCOL \
-           PATH_INFO QUERY_STRING CONTENT_TYPE CONTENT_LENGTH
+           PATH_INFO QUERY_STRING CONTENT_TYPE CONTENT_LENGTH cgilite_headers
 
     # Try to serve multiple requests, provided that script serves a
     # Content-Length header.
@@ -264,7 +270,7 @@ HEADER(){
     str="${str#*${BR}${1}: }"
     printf %s "${str%%${BR}*}"
   else
-    local var="HTTP_$(printf %s "$1" |tr a-z- A-Z-)"
+    local var="HTTP_$(printf %s "$1" |tr a-z- A-Z_)"
     eval "[ \"\$$var\" ] && printf %s \"\$$var\" || return 1"
     # eval "printf %s \"\$HTTP_$(printf %s "${1}" |tr a-z A-Z |tr -c A-Z _)\""
   fi
@@ -294,7 +300,7 @@ HTML(){
     \]*) out="${out}]";      str="${str#?}";;
     "${CR}"*) out="${out}
"; str="${str#?}";;
     "${BR}"*) out="${out}
"; str="${str#?}";;
-    *) out="${out}${str%%[]&<>\"\'[]*}"; str="${str#"${str%%[]&<>\"\'[]*}"}";;
+    *) out="${out}${str%%[]&<>\"\'${CR}${BR}[]*}"; str="${str#"${str%%[]&<>\"\'${CR}${BR}[]*}"}";;
   esac; done
   printf %s "$out"
 }
@@ -307,6 +313,7 @@ URL(){
     \&*) out="${out}%26"; str="${str#?}";;
     \"*) out="${out}%22"; str="${str#?}";;
     \'*) out="${out}%27"; str="${str#?}";;
+    \`*) out="${out}%60"; str="${str#?}";;
     \?*) out="${out}%3F"; str="${str#?}";;
     \#*) out="${out}%23"; str="${str#?}";;
     \[*) out="${out}%5B"; str="${str#?}";;