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: https://git.plutz.net/?p=cgilite;a=commitdiff_plain;h=HEAD;hp=a48f2023821b9ca8840a111f381d53301c8e9b4b 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/markdown.awk b/markdown.awk index c08d856..34879d2 100755 --- a/markdown.awk +++ b/markdown.awk @@ -158,18 +158,18 @@ function inline( line, LOCAL, len, text, code, href, guard ) { href = gensub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\1", 1, substr(line, 1, len) ); text = gensub(/^\[\[([^]|]+)(\|([^]]+))?\]\]/, "\\3", 1, substr(line, 1, len) ); if ( ! text ) text = href; - return "" HTML(text) "" inline( substr( line, len + 1) ); + return "" HTML(text) "" inline( substr( line, len + 1) ); # quick links ("automatic links" in md doc) } else if ( match( line, /^<[a-zA-Z]+:\/\/([-\.[:alnum:]]+)(:[0-9]*)?(\/[^>]*)?>/ ) ) { len = RLENGTH; - href = URL( substr( line, 2, len - 2) ); + href = HTML( substr( line, 2, len - 2) ); return "" href "" inline( substr( line, len + 1) ); # quick link email } else if ( match( line, /^<[a-zA-Z0-9.!#$%&'\''*+\/=?^_`{|}~-]+@[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>/ ) ) { len = RLENGTH; - href = URL( substr( line, 2, len - 2) ); + href = HTML( substr( line, 2, len - 2) ); return "" href "" inline( substr( line, len + 1) ); # Verbatim inline HTML @@ -192,7 +192,7 @@ function inline( line, LOCAL, len, text, code, href, guard ) { gsub(/\\/, "", href); gsub(/\\/, "", title); gsub(/[\n\t]+/, " ", title); - return "" \ + return "" \ inline( text ) "" inline( substr( line, len + 1) ); # reference style links @@ -202,9 +202,9 @@ function inline( line, LOCAL, len, text, code, href, guard ) { id = gensub(/^\[([^\n]+)\] ?\[([^\n]*)\].*/, "\\2", 1, substr(line, 1, len) ); if ( ! id ) id = text; if ( rl_href[id] && rl_title[id] ) { - return "" inline(text) "" inline( substr( line, len + 1) ); + return "" inline(text) "" inline( substr( line, len + 1) ); } else if ( rl_href[id] ) { - return "" inline(text) "" inline( substr( line, len + 1) ); + return "" inline(text) "" inline( substr( line, len + 1) ); } else { return "" HTML(substr(line, 1, len)) inline( substr(line, len + 1) ); } @@ -234,7 +234,7 @@ function inline( line, LOCAL, len, text, code, href, guard ) { gsub(/^[\t ]+$/, "", text); gsub(/\\/, "", href); gsub(/\\/, "", title); gsub(/[\n\t]+/, " ", title); - return "\""" inline( substr( line, len + 1) ); @@ -245,10 +245,10 @@ function inline( line, LOCAL, len, text, code, href, guard ) { id = gensub(/^!\[([^\n]*)\] ?\[([^\n]*)\].*/, "\\2", 1, substr(line, 1, len) ); if ( ! id ) id = text; if ( rl_href[id] && rl_title[id] ) { - return "\""" \ + return "\""" \ inline( substr( line, len + 1) ); } else if ( rl_href[id] ) { - return "\""" \ + return "\""" \ inline( substr( line, len + 1) ); } else { return "" HTML(substr(line, 1, len)) inline( substr(line, len + 1) ); @@ -663,8 +663,8 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, gsub(/^[\t ]+$/, "", text); gsub(/\\/, "", href); - return "
" \ - "\""" \ + "\""" \ (title?"
" inline(title) "
":"") \ "
\n\n" \ @@ -677,14 +677,14 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, id = gensub(/^!\[([^\n]*)\] ?\[([^\n]*)\](\n.*)?$/, "\\2", 1, block); if ( ! id ) id = text; if ( rl_href[id] && rl_title[id] ) { - return "
" \ - "\""" \ + return "
" \ + "\""" \ "
" inline(rl_title[id]) "
" \ "
\n\n" \ _block( substr( block, len + 1) ); } else if ( rl_href[id] ) { - return "
" \ - "\""" \ + return "
" \ + "\""" \ "
\n\n" \ _block( substr( block, len + 1) ); } else { 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 diff --git a/users.sh b/users.sh index c924789..32299ff 100755 --- a/users.sh +++ b/users.sh @@ -621,7 +621,7 @@ w_user_invite(){ if [ "$(GET user_confirm)" ]; then w_user_confirm - elif [ "$USER_ID" -a "$SENDMAIL" ]; then + elif [ "$USER_ID" -a "$USER_REQUIREEMAIL" = true ]; then w_user_invite_email elif [ "$USER_ID" ]; then uid="$(timeid)"