Golang html/template.JSEscaper function example
package html/template
JSEscaper returns the escaped JavaScript equivalent of the textual representation of its arguments.
Golang html/template.JSEscaper function usage example
package main
import (
"fmt"
"html/template"
)
func main() {
a := "<script>alert('xss!')</script>"
b := "<script>alert('javascript')</script>"
final := template.HTMLEscaper(a, b)
fmt.Println(final)
}
Output :
<script>alert('xss!')</script>
<script>alert('javascript')</script>
Reference :
Advertisement
Something interesting
Tutorials
+7.4k Android Studio : How to detect camera, activate and capture example
+5.3k Python : Convert(cast) string to bytes example
+13.3k Golang : Linear algebra and matrix calculation example
+5.3k Javascript : Change page title to get viewer attention
+27.2k Golang : Find files by name - cross platform example
+4.7k Javascript : Access JSON data example
+22.9k Golang : Test file read write permission example
+33k Golang : How to check if a date is within certain range?
+8.8k Golang : HTTP Routing with Goji example
+17.8k Golang : Defer function inside init()
+7.8k Golang : Lock executable to a specific machine with unique hash of the machine
+6.1k Java : Human readable password generator