X-Git-Url: http://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=server.sh;h=c49c0d8e7f1fd1039eb147a283499c6e6aa037d3;hp=4eb253ffe2696f5ac5be0b60be18d91da74b2511;hb=1a1d111199b770c092e1b16a7e03568d3d911b79;hpb=b3455673aa27e118f55b91fe69a4b07c42dbe3a7 diff --git a/server.sh b/server.sh index 4eb253f..c49c0d8 100755 --- a/server.sh +++ b/server.sh @@ -34,6 +34,10 @@ sed -unr ' h s;^(GET|HEAD|POST) ([^\?]*)\??(.+)? (HTTP\/[0-9]\.[0-9])\r?$;export REQUEST_METHOD='\''\1'\'';p g + s;^(GET|HEAD|POST) ([^\?]*\??.*) (HTTP\/[0-9]\.[0-9])\r?$;\2; + s;'\'';'\''\\'\'''\'';g + s;^.*$;export REQUEST_URI='\''&'\'';p + g s;^(GET|HEAD|POST) ([^\?]*)\??(.+)? (HTTP\/[0-9]\.[0-9])\r?$;\2; s;'\'';'\''\\'\'''\'';g s;^.*$;export PATH_INFO='\''&'\'';p @@ -66,14 +70,15 @@ sed -unr ' ) HTTP_format(){ - LC_ALL=C sed -rn ' + LC_ALL=C sed -urn ' :A /^\r?$/!{H;n;bA} g - s;^(\r?\n)*;; + s;^(\r?\n)*;;; + s;([^\r])\n;\1\r\n;g; aConnection: close\r\n\r - /^HTTP\/[0-9]\.[0-9] [1-5][0-9][0-9] .*/bX + /^Status: *[1-5][0-9][0-9] .*/{s;^Status: *;HTTP/1.1 ;; bX} s;^(.+\n)?Location: .*$;HTTP/1.1 302 Found\r\n&; s;^(.+\n)?Content-Type: .*$;HTTP/1.1 200 OK\r\n&; @@ -85,9 +90,10 @@ HTTP_format(){ ' } -PATH_INFO="$(invalidate "${PATH_INFO}" '(^|.*/)\.\./.*' '')" -if [ -z "$QUERY_STRING" -a -f "$_DATA/$PATH_INFO" ]; then - . "$_EXEC/shcgi/static.sh" "$_DATA/$PATH_INFO" +if [ -z "$QUERY_STRING" ]; then + PATH_INFO="$(printf "$(printf %s "$PATH_INFO" |sed 's:+: :g;s:\\:\\\\:g;s:%:\\x:g')")" + PATH_INFO="$(invalidate "${PATH_INFO}" '(^|.*/)\.\./.*' '')" + [ -f "${treeroot:-${_DATA}}/$PATH_INFO" ] && . "$_EXEC/shcgi/static.sh" "${treeroot:-${_DATA}}/$PATH_INFO" exit 0 fi |HTTP_format