mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
2cfd1040a9
* Added misset UA setting * Update doc_ua.fql * Delete ferret_embedding_basic.go
26 lines
674 B
Go
26 lines
674 B
Go
package strings
|
|
|
|
import (
|
|
"context"
|
|
"html"
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
)
|
|
|
|
// EscapeHTML 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.
|
|
// @param (String) - Uri to escape.
|
|
// @returns String - Escaped string.
|
|
func EscapeHTML(_ context.Context, args ...core.Value) (core.Value, error) {
|
|
err := core.ValidateArgs(args, 1, 1)
|
|
|
|
if err != nil {
|
|
return values.None, err
|
|
}
|
|
|
|
return values.NewString(html.EscapeString(args[0].String())), nil
|
|
}
|