From: Paul Hänsch Date: Thu, 5 Jul 2018 12:40:11 +0000 (+0200) Subject: path cononicalization function (works on non-exist pathes unlike realpath) X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=6940bf78a6d2dd6080f8d7f720eb66c17d1a11db;p=cgilite path cononicalization function (works on non-exist pathes unlike realpath) --- diff --git a/cgilite.sh b/cgilite.sh index f227d27..13cdb3c 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -50,7 +50,7 @@ HEX_DECODE(){ ')" } -if [ -z "$REQUEST_METHOD" -a -z "$SERVER_PROTOCOL" ]; then +if [ -z "$REQUEST_METHOD" ]; then # no webserver variables means we are running via inetd / ncat # so use builtin web server @@ -173,6 +173,18 @@ URL(){ | tr , % } +PATH(){ + printf %s "$1" \ + | sed -r 's;^.*$;/&/;; s;/+;/;g; + :X; + s;^/../;/;; s;/./;/;g; + tX; + s;/[^/]+/../;/;; + tX; + s;^(/.*)/$;\1;' +} + + SET_COOKIE(){ case "$1" in ''|0|session) expire='';;