Golang text/template.JSEscapeString() function example
package text/template
Golang text/template.JSEscapeString() function usage example
package main
import (
"fmt"
"text/template"
)
func main() {
s := "<script>alert('xss attack!')</script>"
final := template.JSEscapeString(s)
fmt.Println(final)
}
Output :
\x3Cscript\x3Ealert(\'xss attack!\')\x3C/script\x3E
Reference :
Advertisement
Something interesting
Tutorials
+14.2k Golang : How to determine if a year is leap year?
+6.3k Golang : Dealing with backquote
+6.3k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+5.3k Golang : Check if a word is countable or not
+23.8k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+11k PHP : Convert(cast) bigInt to string
+11.6k Golang : Change date format to yyyy-mm-dd
+7k Golang : Pat multiplexer routing example
+11.4k Golang : How to determine a prime number?
+8.5k Golang : Check if integer is power of four example
+11.7k Golang : Generate DSA private, public key and PEM files example
+13.2k Golang : List objects in AWS S3 bucket