Golang html.EscapeString function example
package html
EscapeString escapes special characters like "<" to become "<". It escapes only five such characters: <, >, &, ' and ". UnescapeString(EscapeString(s)) == s always holds, but the converse isn't always true.
Golang html.EscapeString function usage example
package main
import (
"fmt"
"html"
)
func main() {
s := "<script>alert('xss')</script>"
fmt.Println(html.EscapeString(s))
}
Output :
<script>alert('xss')</script>
Reference :
Advertisement
Something interesting
Tutorials
+9.2k Golang : does not implement flag.Value (missing Set method)
+8.3k Golang : Auto-generate reply email with text/template package
+12.7k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+9.6k Javascript : Read/parse JSON data from HTTP response
+12.4k Golang : Encrypt and decrypt data with x509 crypto
+10.1k Golang : Check a web page existence with HEAD request example
+5.9k Golang : Use NLP to get sentences for each paragraph example
+7.5k Golang : Get YouTube playlist
+8.1k Golang : HTTP Server Example
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+16.5k Golang : Execute terminal command to remote machine example