mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-08 13:13:47 -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")
|
||||
# ------------------------------------------------------
|
||||
escape() { echo $@ | sed 's/[]\.|$(){}?+*^]/\\&/g'; }
|
||||
escape() { echo "${@}" | sed 's/[]\.|$(){}?+*^]/\\&/g'; }
|
||||
|
||||
# needSudo
|
||||
# ------------------------------------------------------
|
||||
@@ -520,6 +520,12 @@ htmlDecode() {
|
||||
echo "${1}" | sed -f "${SOURCEPATH}/htmlDecode.sed"
|
||||
}
|
||||
|
||||
htmlEncode() {
|
||||
# Encode HTML characters with sed
|
||||
# Usage: htmlEncode <string>
|
||||
echo "${1}" | sed -f "${SOURCEPATH}/htmlEncode.sed"
|
||||
}
|
||||
|
||||
|
||||
urlencode() {
|
||||
# URL encoding/decoding from: https://gist.github.com/cdown/1163649
|
||||
|
||||
Reference in New Issue
Block a user