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
+7.8k Swift : Convert (cast) String to Double
+26.7k Golang : How to check if a connection to database is still alive ?
+7.6k Android Studio : AlertDialog to get user attention example
+7.5k Golang : Process json data with Jason package
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+19.3k Golang : Get RGBA values of each image pixel
+6.1k nginx : force all pages to be SSL
+9.6k Golang : How to generate Code 39 barcode?
+32.4k Golang : Math pow(the power of x^y) example
+7.2k Golang : Dealing with postal or zip code example
+5.2k Golang : Issue HTTP commands to server and port example
+6.2k PHP : Get client IP address