From: Paul Hänsch Date: Mon, 19 Jun 2023 13:32:26 +0000 (+0200) Subject: Squashed 'cgilite/' changes from 8fd595c0..8ce6dce8 X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=c15fd72ed0c779b872360a2546ff60767772d8ee;p=shellwiki Squashed 'cgilite/' changes from 8fd595c0..8ce6dce8 8ce6dce8 bugfix: do not accidentally strip white spaces from code spans c4ba9cc2 Include backtick (`) in URL escape handling d61539cd bugfix: prevent endless loop in HEX_DECODE, copy non-hex-digits unchanged git-subtree-dir: cgilite git-subtree-split: 8ce6dce8725f84096aebcf1a4063eaeee754b92a --- diff --git a/cgilite.sh b/cgilite.sh index b51ee8e..76c91b2 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -85,6 +85,12 @@ HEX_DECODE(){ # will be copied to the output literally while [ "$in" ]; do + [ "$pfx" ] || case $in in + [0-9a-fA-F][0-9a-fA-F]*):;; + ?*) out="${out}${in%%"${in#?}"}" + in="${in#?}"; continue;; + esac + case $in in "$pfx"[0-9a-fA-F][0-9a-fA-F]*) in="${in#${pfx}}";; \\*) in="${in#?}"; out="${out}\\\\"; continue;; @@ -307,6 +313,7 @@ URL(){ \&*) out="${out}%26"; str="${str#?}";; \"*) out="${out}%22"; str="${str#?}";; \'*) out="${out}%27"; str="${str#?}";; + \`*) out="${out}%60"; str="${str#?}";; \?*) out="${out}%3F"; str="${str#?}";; \#*) out="${out}%23"; str="${str#?}";; \[*) out="${out}%5B"; str="${str#?}";; diff --git a/markdown.awk b/markdown.awk index af3d722..3fa248d 100755 --- a/markdown.awk +++ b/markdown.awk @@ -93,6 +93,7 @@ function URL ( text ) { gsub( /&/, "%26", text ); gsub( /"/, "%22", text ); gsub( /'/, "%27", text ); + gsub( /`/, "%60", text ); gsub( /\?/, "%3F", text ); gsub( /#/, "%23", text ); gsub( /\[/, "%5B", text ); @@ -130,7 +131,7 @@ function inline( line, LOCAL, len, code, href, guard ) { code = substr( line, len + 1, match( substr(line, len + 1), guard ) - 1) len = 2 * length(guard) + length(code) # strip single surrounding white spaces - code = gensub( / (.*) /, "\\1", "1" , code) + code = gensub( /^ | $/, "", "g" , code) # escape HTML within code span gsub( /&/, "\\&", code ); gsub( //, "\\>", code ); return "" code "" inline( substr( line, len + 1 ) )