summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/template.source.sh25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/lib/template.source.sh b/src/lib/template.source.sh
index 90e0ebd..0f038e4 100644
--- a/src/lib/template.source.sh
+++ b/src/lib/template.source.sh
@@ -1,13 +1,9 @@
_html_escape() {
- local text="$1"; shift
-
- text=${text//&/\&}
- text=${text//</\&lt;}
- text=${text//>/\&gt;}
- text=${text//\"/\&quot;}
- text=${text//\'/\&#39;}
+ local -r text="$1"; shift
+ local escaped_text
- printf '%s\n' "$text"
+ html_escape_to escaped_text "$text"
+ printf '%s\n' "$escaped_text"
}
html_escape_to() {
@@ -24,16 +20,11 @@ html_escape_to() {
}
_css_string_escape() {
- local text="$1"; shift
-
- text=${text//\\/\\\\}
- text=${text//&/\\000026}
- text=${text//</\\00003c}
- text=${text//>/\\00003e}
- text=${text//\"/\\000022}
- text=${text//\'/\\000027}
+ local -r text="$1"; shift
+ local escaped_text
- printf '%s\n' "$text"
+ css_string_escape_to escaped_text "$text"
+ printf '%s\n' "$escaped_text"
}
css_string_escape_to() {