]> git.plutz.net Git - cgilite/commitdiff
new function RXLITERAL() for escaping regex characters master
authorPaul Hänsch <paul@plutz.net>
Tue, 14 May 2024 10:11:55 +0000 (12:11 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 14 May 2024 10:11:55 +0000 (12:11 +0200)
cgilite.awk
common.css
storage.sh

index f16ed6a3281746d6182cd4f340eb15910f6c5a87..ebf44113d1b3333eec25166a81201d01b3cd3703 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/env awk -f
 
 #!/bin/env awk -f
 
+function debug(t) { printf "%s\n", t >>"/dev/stderr"; }
+
 function PATH( str,    seg, out ) {
   while ( str ) {
     seg = str;
 function PATH( str,    seg, out ) {
   while ( str ) {
     seg = str;
@@ -151,8 +153,9 @@ BEGIN {
   split("", _GET); split("", _POST); split("", _REF);
   split("", _HEADER); split("", _COOKIE);
 
   split("", _GET); split("", _POST); split("", _REF);
   split("", _HEADER); split("", _COOKIE);
 
-  if ( ENVIRON["REQUEST_METHOD"] )
+  if ( ENVIRON["REQUEST_METHOD"] ) {
     _cgilite_headers();
     _cgilite_headers();
-  else
+  } else {
     _cgilite_request();
     _cgilite_request();
+  }
 }
 }
index 30c3942eb5d8a2b4ef42e3fceb972b2d8c54a495..16e99f23befd1f945ee7efbd71707a48ccd367ad 100644 (file)
@@ -31,7 +31,7 @@ a {
   color: #068;
   word-break: break-word;
 }
   color: #068;
   word-break: break-word;
 }
-a.button {
+a.button, label.button {
   font-style: inherit;
   text-decoration: inherit;
   color: inherit;
   font-style: inherit;
   text-decoration: inherit;
   color: inherit;
@@ -86,7 +86,7 @@ h1 {
 }
 h2 { font-size: 1.125em; }
 
 }
 h2 { font-size: 1.125em; }
 
-select, input, button, textarea, a.button {
+select, input, button, textarea, a.button, label.button {
   display: inline-block;
   color: #000; background-color: #FFF;
   border: .5pt solid;
   display: inline-block;
   color: #000; background-color: #FFF;
   border: .5pt solid;
@@ -103,7 +103,7 @@ input[type=radio], input[type=checkbox] {
 }
 input[type=number] { text-align: right; padding-right: 0; }
 
 }
 input[type=number] { text-align: right; padding-right: 0; }
 
-button, input[type=button], a.button {
+button, input[type=button], a.button, label.button {
   box-shadow: .125em .125em .25em;
   cursor: pointer;
 }
   box-shadow: .125em .125em .25em;
   cursor: pointer;
 }
index 17ea0d051eaf27233f8b5cd96f7396974c7a87f1..5c61df0a041e75df0e1ee0e81aa0c09078cdabc1 100755 (executable)
@@ -94,6 +94,21 @@ UNSTRING(){
   printf '%s\n' "$out"
 }
 
   printf '%s\n' "$out"
 }
 
+RXLITERAL(){
+  # sed -E 's;[].*+?^${}()|\[];\\&;g'
+  local in out=''
+  [ $# -gt 0 ] && in="$*" || in="$(cat)"
+  while [ "$in" ]; do case $in in
+    [.+^\$\{\}\(\)\[\]\*\?\|\\]*)
+      out="${out}\\${in%"${in#?}"}"; in="${in#?}";
+      ;;
+    *)out="${out}${in%%[.+^\$\{\}\(\)\[\]\*\?\|\\]*}"
+      in="${in#"${in%%[.+^\$\{\}\(\)\[\]\*\?\|\\]*}"}"
+      ;;
+  esac; done
+  printf '%s\n' "$out"
+}
+
 DBM() {
   local file="$1" cmd="$2"
   local k v key value
 DBM() {
   local file="$1" cmd="$2"
   local k v key value