Golang html/template.HTMLEscaper function example
package html/template
HTMLEscaper returns the escaped HTML equivalent of the textual representation of its arguments.
Golang html/template.HTMLEscaper function usage example
package main
import (
"fmt"
"html/template"
)
func main() {
a := "<script>alert('xss attack!')</script>"
b := "<p>This is a paragraph</p>"
final := template.HTMLEscaper(a, b)
fmt.Println(final)
}
Output :
<script>alert('xss attack!')</script><p>This is a paragraph</p>
References :
Advertisement
Something interesting
Tutorials
+8.4k Golang : Convert word to its plural form example
+25.9k Golang : How to read integer value from standard input ?
+10k Golang : Get escape characters \u form from unicode characters
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+10.6k Golang : Flip coin example
+7.5k Golang : Dealing with struct's private part
+18.6k Golang : Iterating Elements Over A List
+5.8k Javascript : How to replace HTML inside <div>?
+4.7k JavaScript: Add marker function on Google Map
+34.6k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+19.9k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+6k Golang : Function as an argument type example