]> git.plutz.net Git - cgilite/commitdiff
bugfix: prevent endless loop in HEX_DECODE, copy non-hex-digits unchanged
authorPaul Hänsch <paul@plutz.net>
Mon, 19 Jun 2023 13:24:26 +0000 (15:24 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 19 Jun 2023 13:24:26 +0000 (15:24 +0200)
cgilite.sh

index b51ee8ec9e4c938413817bd8dff00ffdb3ab1d82..b915a8fb83e4971817ad98ba0818d2a15635bfaa 100755 (executable)
@@ -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;;