ad_js_escape (public)
ad_js_escape string
Defined in packages/acs-tcl/tcl/text-html-procs.tcl
Return supplied string with invalid javascript characters property escaped. This makes possible to use the string safely inside javascript code.
- Parameters:
- string (required)
- Author:
- Antonio Pisano
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- ad_js_escape
Source code: string map [list \n \\n \b \\b \f \\f \r \\r \t \\t \v \\v \" {\"} ' {\'}] $string # 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 $stringXQL Not present: Generic, PostgreSQL, Oracle