]> git.plutz.net Git - serve0/commitdiff
Merge commit 'f38e4332eb9d1244b9a421c6e34436aaccb541eb'
authorPaul Hänsch <paul@plutz.net>
Tue, 16 Nov 2021 03:29:40 +0000 (04:29 +0100)
committerPaul Hänsch <paul@plutz.net>
Tue, 16 Nov 2021 03:29:40 +0000 (04:29 +0100)
1  2 
cgilite/cgilite.sh

diff --combined cgilite/cgilite.sh
index a0a96d1c9191ec2cf849105bd0b910dbfe62db23,03541b41829355d69287596ed40041dccf8545e1..03541b41829355d69287596ed40041dccf8545e1
@@@ -281,21 -281,18 +281,18 @@@ HTML()
    # Also escape [, ], and \n for use in html-sh
    local str out
    [ $# -eq 0 ] && str="$(cat)" || str="$*"
-   while [ "$str" ]; do
-     case $str in
-       \&*) out="${out}&amp;";;
-       \<*) out="${out}&lt;";;
-       \>*) out="${out}&gt;";;
-       \"*) out="${out}&quot;";;
-       \'*) out="${out}&#x27;";;
-       \[*) out="${out}&#x5B;";;
-       \]*) out="${out}&#x5D;";;
-       "${CR}"*) out="${out}&#x0D;";;
-       "${BR}"*) out="${out}&#x0A;";;
-       *) out="${out}${str%"${str#?}"}";;
-     esac
-     str="${str#?}"
-   done
+   while [ "$str" ]; do case $str in
+     \&*) out="${out}&amp;";       str="${str#?}";;
+     \<*) out="${out}&lt;";        str="${str#?}";;
+     \>*) out="${out}&gt;";        str="${str#?}";;
+     \"*) out="${out}&quot;";      str="${str#?}";;
+     \'*) out="${out}&#x27;";      str="${str#?}";;
+     \[*) out="${out}&#x5B;";      str="${str#?}";;
+     \]*) out="${out}&#x5D;";      str="${str#?}";;
+     "${CR}"*) out="${out}&#x0D;"; str="${str#?}";;
+     "${BR}"*) out="${out}&#x0A;"; str="${str#?}";;
+     *) out="${out}${str%%[]&<>\"\'[]*}"; str="${str#"${str%%[]&<>\"\'[]*}"}";;
+   esac; done
    printf %s "$out"
  }
  
@@@ -303,24 -300,21 +300,21 @@@ URL()
    # Escape pathes, so they can be used in link tags and HTTP Headers
    local str out
    [ $# -eq 0 ] && str="$(cat)" || str="$*"
-   while [ "$str" ]; do
-     case $str in
-       \&*) out="${out}%26";;
-       \"*) out="${out}%22";;
-       \'*) out="${out}%27";;
-       \?*) out="${out}%3F";;
-       \#*) out="${out}%23";;
-       \[*) out="${out}%5B";;
-       \]*) out="${out}%5D";;
-       \ *) out="${out}%20";;
-       "       "*) out="${out}%09";;
-       "${CR}"*) out="${out}%0D";;
-       "${BR}"*) out="${out}%0A";;
-       %*) out="${out}%25";;
-       *) out="${out}${str%"${str#?}"}";;
-     esac
-     str="${str#?}"
-   done
+   while [ "$str" ]; do case $str in
+     \&*) out="${out}%26"; str="${str#?}";;
+     \"*) out="${out}%22"; str="${str#?}";;
+     \'*) out="${out}%27"; str="${str#?}";;
+     \?*) out="${out}%3F"; str="${str#?}";;
+     \#*) out="${out}%23"; str="${str#?}";;
+     \[*) out="${out}%5B"; str="${str#?}";;
+     \]*) out="${out}%5D"; str="${str#?}";;
+     \ *) out="${out}%20"; str="${str#?}";;
+     " "*) out="${out}%09"; str="${str#?}";;
+     "${CR}"*) out="${out}%0D"; str="${str#?}";;
+     "${BR}"*) out="${out}%0A"; str="${str#?}";;
+     %*) out="${out}%25"; str="${str#?}";;
+     *) out="${out}${str%%[]&\"\'#     ${CR}${BR}[]*}"; str="${str#"${str%%[]&\"\'#    ${CR}${BR}[]*}"}";;
+   esac; done
    printf %s "$out"
  }