From 69f8408db61b6f4905f7e4af03faa473ab435451 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 13 Sep 2021 19:29:46 +0200 Subject: [PATCH] Squashed 'cgilite/' changes from 2218e82..a76f6a5 a76f6a5 allow suppression of default session cookie bcca3c0 STRING encodes empty values as backslash for easyer `read`ing of TAB-DBs, UNSTRING produces trailing newline for consistent output of encoded \n, obsoleted `sed` $UNSTRING code 9884092 typo in cli parsing git-subtree-dir: cgilite git-subtree-split: a76f6a5931782adbae717678f8f92569ed0d5bcb --- cgilite.sh | 6 +++--- session.sh | 7 ++++++- storage.sh | 19 ++----------------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/cgilite.sh b/cgilite.sh index 6a4a648..a2aa329 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -44,9 +44,9 @@ for cgilite_arg in "$@"; do case $cgilite_arg in esac; done unset cgilite_arg -_EXEC="${EXEC:-${0%/*}}" -_DATA="${DATA:-.}" -_EXEC="${_EXEC%/}" _DATA="${_DATA%/}" _BASE="${BASE%/}" +_EXEC="${_EXEC:-${0%/*}}" +_DATA="${_DATA:-.}" +_EXEC="${_EXEC%/}" _DATA="${_DATA%/}" _BASE="${_BASE%/}" # Carriare Return and Line Break characters for convenience CR=" " diff --git a/session.sh b/session.sh index ca931fa..5b36ae0 100755 --- a/session.sh +++ b/session.sh @@ -114,6 +114,11 @@ SESSION_VAR() { fi } +SESSION_COOKIE() { + SET_COOKIE 0 session="$SESSION_KEY" Path=/ SameSite=Strict HttpOnly +} + SESSION_KEY="$(update_session)" -SET_COOKIE 0 session="$SESSION_KEY" Path=/ SameSite=Strict HttpOnly SESSION_ID="${SESSION_KEY%% *}" + +[ "$1" = nocookie ] || SESSION_COOKIE diff --git a/storage.sh b/storage.sh index 77ee29c..22e6acc 100755 --- a/storage.sh +++ b/storage.sh @@ -66,11 +66,6 @@ RELEASE(){ fi } -# STRING=' -# s;\\;\\\\;g; s;\t;\\t;g; -# s;\n;\\n;g; s;\r;\\r;g; -# s;\+;\\+;g; s; ;+;g; -# ' STRING(){ local in out='' [ $# -gt 0 ] && in="$*" || in="$(cat)" @@ -83,19 +78,9 @@ STRING(){ " "*) out="${out}+"; in="${in# }" ;; *) out="${out}${in%%[\\${CR}${BR} + ]*}"; in="${in#"${in%%[\\${BR}${CR} + ]*}"}" ;; esac; done - printf '%s' "$out" + printf '%s' "${out:-\\}" } -UNSTRING=' - :UNSTRING_X - s;((^|[^\\])(\\\\)*)\\n;\1\n;g; - s;((^|[^\\])(\\\\)*)\\t;\1\t;g; - s;((^|[^\\])(\\\\)*)\\r;\1\r;g; - s;((^|[^\\])(\\\\)*)\+;\1 ;g; - tUNSTRING_X; - s;((^|[^\\])(\\\\)*)\\\+;\1+;g; - s;\\\\;\\;g; -' UNSTRING(){ local in out='' [ $# -gt 0 ] && in="$*" || in="$(cat)" @@ -109,7 +94,7 @@ UNSTRING(){ \\*) in="${in#\\}" ;; *) out="${out}${in%%[\\+]*}"; in="${in#"${in%%[\\+]*}"}" ;; esac; done - printf '%s' "$out" + printf '%s\n' "$out" } DBM() { -- 2.39.2