]> git.plutz.net Git - serve0/commitdiff
Squashed 'cgilite/' changes from 9884092..a76f6a5
authorPaul Hänsch <paul@plutz.net>
Mon, 13 Sep 2021 17:38:52 +0000 (19:38 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 13 Sep 2021 17:38:52 +0000 (19:38 +0200)
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

git-subtree-dir: cgilite
git-subtree-split: a76f6a5931782adbae717678f8f92569ed0d5bcb

session.sh
storage.sh

index ca931fad9aa662ec338820bdc88be9f5018aba24..5b36ae032af4e818af91d4b73190a9f83614da15 100755 (executable)
@@ -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
index 77ee29c06243eae9359c03125626a46f498cded4..22e6accbcba7cddd75bbaec0235a174b4aa53bd3 100755 (executable)
@@ -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() {