From: Paul Hänsch Date: Tue, 14 May 2024 10:11:55 +0000 (+0200) Subject: new function RXLITERAL() for escaping regex characters X-Git-Url: http://git.plutz.net/?p=cgilite;a=commitdiff_plain;h=refs%2Fheads%2Fmaster;hp=397847dd01a44b7a5a26b6c6d16a61a42079a542 new function RXLITERAL() for escaping regex characters --- diff --git a/cgilite.awk b/cgilite.awk index f16ed6a..ebf4411 100644 --- a/cgilite.awk +++ b/cgilite.awk @@ -1,5 +1,7 @@ #!/bin/env awk -f +function debug(t) { printf "%s\n", t >>"/dev/stderr"; } + function PATH( str, seg, out ) { while ( str ) { seg = str; @@ -151,8 +153,9 @@ BEGIN { split("", _GET); split("", _POST); split("", _REF); split("", _HEADER); split("", _COOKIE); - if ( ENVIRON["REQUEST_METHOD"] ) + if ( ENVIRON["REQUEST_METHOD"] ) { _cgilite_headers(); - else + } else { _cgilite_request(); + } } diff --git a/common.css b/common.css index 30c3942..16e99f2 100644 --- a/common.css +++ b/common.css @@ -31,7 +31,7 @@ a { color: #068; word-break: break-word; } -a.button { +a.button, label.button { font-style: inherit; text-decoration: inherit; color: inherit; @@ -86,7 +86,7 @@ h1 { } 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; @@ -103,7 +103,7 @@ input[type=radio], input[type=checkbox] { } 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; } diff --git a/storage.sh b/storage.sh index 17ea0d0..5c61df0 100755 --- a/storage.sh +++ b/storage.sh @@ -94,6 +94,21 @@ UNSTRING(){ 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