X-Git-Url: http://git.plutz.net/?p=cgilite;a=blobdiff_plain;f=cgilite.sh;h=f766ee2a425591245926952a5b961dde86cac4ee;hp=2e538324c0a8b5ec45f6fb2235f254fcf359db22;hb=a1caf91a5e6ab2d13790ec6a0c1eaf2b4030a0e8;hpb=238f0f8a2932b5ba66f7139c227eaaeb5dd7a013 diff --git a/cgilite.sh b/cgilite.sh index 2e53832..f766ee2 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -18,6 +18,9 @@ # You should have received a copy of the GNU Affero General Public License # along with CGIlite. If not, see . +[ -n "$include_cgilite" ] && return 0 +# guard set after webserver part + # ksh and zsh workaround # set -o posix # ksh, not portable setopt -o OCTAL_ZEROES 2>&- @@ -27,8 +30,6 @@ BR=' ' cgilite_timeout=2 -debug(){ [ $# -gt 0 ] && printf '%s\n' "$@" >&2 || tee -a /dev/stderr; } - PATH(){ local str seg out [ $# -eq 0 ] && str="$(cat)" || str="$*" @@ -121,11 +122,14 @@ if [ -z "$REQUEST_METHOD" ]; then exit 0 fi +include_cgilite="$0" + if [ "${REQUEST_METHOD}" = POST -a "${CONTENT_LENGTH:-0}" -gt 0 -a \ "${CONTENT_TYPE}" = "application/x-www-form-urlencoded" ]; then cgilite_post="$(head -c "$CONTENT_LENGTH")" fi +debug(){ [ $# -gt 0 ] && printf '%s\n' "$@" >&2 || tee -a /dev/stderr; } [ "${DEBUG+x}" ] && env >&2 cgilite_count(){ @@ -202,6 +206,7 @@ HTML(){ \'*) out="${out}'";; \[*) out="${out}[";; \]*) out="${out}]";; + "${CR}"*) out="${out} ";; "${BR}"*) out="${out} ";; *) out="${out}${str%"${str#?}"}";; esac @@ -224,6 +229,8 @@ URL(){ \[*) out="${out}%5B";; \]*) out="${out}%5D";; \ *) out="${out}%20";; + " "*) out="${out}%09";; + "${CR}"*) out="${out}%0D";; "${BR}"*) out="${out}%0A";; %*) out="${out}%25";; *) out="${out}${str%"${str#?}"}";;