github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/strings/escape.go (about) 1 package strings 2 3 import ( 4 "context" 5 "html" 6 7 "github.com/MontFerret/ferret/pkg/runtime/core" 8 "github.com/MontFerret/ferret/pkg/runtime/values" 9 ) 10 11 // ESCAPE_HTML escapes special characters like "<" to become "<". It 12 // escapes only five such characters: <, >, &, ' and ". 13 // UnescapeString(EscapeString(s)) == s always holds, but the converse isn't 14 // always true. 15 // @param {String} uri - Uri to escape. 16 // @return {String} - Escaped string. 17 func EscapeHTML(_ context.Context, args ...core.Value) (core.Value, error) { 18 err := core.ValidateArgs(args, 1, 1) 19 20 if err != nil { 21 return values.None, err 22 } 23 24 return values.NewString(html.EscapeString(args[0].String())), nil 25 }