'
cgilite_timeout=2
-PATH(){
- { [ $# -eq 0 ] && cat || printf %s "$*"; } \
- | sed -E 's;^.*$;/&/;; s;/+;/;g;
- :X;
- s;^/\.\./;/;; s;/\./;/;g;
- tX;
- s;/[^/]+/\.\./;/;;
- tX;
- s;^(/.*)/$;\1;'
+PATH(){
+ local str seg out
+ [ $# -eq 0 ] && str="$(cat)" || str="$*"
+ while [ "$str" ]; do
+ seg=${str%%/*}; str="${str#*/}"
+ case $seg in
+ ..) out="${out%/}"; out="${out%/*}/";;
+ .|'') out="${out%/}/";;
+ *) out="${out%/}/${seg}";;
+ esac;
+ [ "$seg" = "$str" ] && break
+ done
+ [ "${str}" -a "${out}" ] && printf %s "$out" || printf %s/ "${out%/}"
}
-
HEX_DECODE='
s;\\;\\\\;g; :HEXDECODE_X; s;%([^0-9A-F]);\\045\1;g; tHEXDECODE_X;
# Hexadecimal { %00 - %FF } will be transformed to octal { \000 - \377 } for posix printf