mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-09 05:33:48 -05:00
We now have a function to encode HTML special characters
This commit is contained in:
@@ -48,7 +48,7 @@ function readFile() {
|
|||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
# usage: var=$(escape "String")
|
# usage: var=$(escape "String")
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
escape() { echo $@ | sed 's/[]\.|$(){}?+*^]/\\&/g'; }
|
escape() { echo "${@}" | sed 's/[]\.|$(){}?+*^]/\\&/g'; }
|
||||||
|
|
||||||
# needSudo
|
# needSudo
|
||||||
# ------------------------------------------------------
|
# ------------------------------------------------------
|
||||||
@@ -520,6 +520,12 @@ htmlDecode() {
|
|||||||
echo "${1}" | sed -f "${SOURCEPATH}/htmlDecode.sed"
|
echo "${1}" | sed -f "${SOURCEPATH}/htmlDecode.sed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
htmlEncode() {
|
||||||
|
# Encode HTML characters with sed
|
||||||
|
# Usage: htmlEncode <string>
|
||||||
|
echo "${1}" | sed -f "${SOURCEPATH}/htmlEncode.sed"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
urlencode() {
|
urlencode() {
|
||||||
# URL encoding/decoding from: https://gist.github.com/cdown/1163649
|
# URL encoding/decoding from: https://gist.github.com/cdown/1163649
|
||||||
|
|||||||
Reference in New Issue
Block a user