Index: openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl,v
diff -u -r1.106 -r1.107
--- openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 17 Nov 2018 16:37:35 -0000 1.106
+++ openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 14 Dec 2018 15:11:53 -0000 1.107
@@ -1356,7 +1356,28 @@
}
}
+ ad_proc -public ad_js_escape {
+ string
+ } {
+ Return supplied string with invalid javascript characters
+ propery escaped. This makes possible to use the string safely
+ inside javascript code.
+ @author Antonio Pisano
+ } {
+ # Escape quotes and backslashes (non greedy)
+ regsub -all {.??([^\\])?('|\"|\\)} $string {\1\\\2} string
+ # Escape characters are replaced with their escape sequence
+ regsub -all {\b} $string {\\b} string
+ regsub -all {\f} $string {\\f} string
+ regsub -all {\n} $string {\\n} string
+ regsub -all {\r} $string {\\r} string
+ regsub -all {\t} $string {\\t} string
+ regsub -all {\v} $string {\\v} string
+
+ return $string
+ }
+
####################
#
# HTML -> Text