Golang html/template.HTMLEscapeString function example
package html/template
HTMLEscapeString returns the escaped HTML equivalent of the plain text data s (1st parameter).
Golang html/template.HTMLEscapeString function usage example
package main
import (
"fmt"
"html/template"
)
func main() {
s := "<script>alert('xss attack!')</script>"
final := template.HTMLEscapeString(s)
fmt.Println(final)
}
Output :
<script>alert('xss attack!')</script>
Reference :
Advertisement
Something interesting
Tutorials
+29.4k Golang : JQuery AJAX post data to server and send data back to client example
+4.8k PHP : Extract part of a string starting from the middle
+6k Golang : Compound interest over time example
+7.1k Golang : Squaring elements in array
+11.7k Golang : Find age or leap age from date of birth example
+8.1k Golang : Variadic function arguments sanity check example
+5.6k Golang : Frobnicate or tweaking a string example
+27.6k PHP : Convert(cast) string to bigInt
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+7.5k Golang : Process json data with Jason package
+4.8k Facebook : How to place save to Facebook button on your website
+47.8k Golang : Convert int to byte array([]byte)