htmlutils

package
v0.8.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoEscapeHtmlEnvVar = "NO_ESCAPE_HTML"
)

Variables

This section is empty.

Functions

func EscapeHtmlInObject

func EscapeHtmlInObject(obj interface{}) interface{}

EscapeHtmlInObject escapes HTML tags in all string fields and properties of an object using reflection Also processes slice/array fields: if slice of objects - processes each object, if slice of strings - escapes each string Can be disabled by setting NO_ESCAPE_HTML environment variable to "true"

func EscapeHtmlInObjectSlice

func EscapeHtmlInObjectSlice(slice interface{}) interface{}

EscapeHtmlInObjectSlice escapes HTML tags in all string fields of objects in a slice using reflection Can be disabled by setting NO_ESCAPE_HTML environment variable to "true"

func EscapeHtmlTags

func EscapeHtmlTags(text string) string

EscapeHtmlTags escapes HTML tags to prevent XSS attacks. First checks if the string contains HTML tags using regex pattern. Only performs escaping if HTML tags are detected. Escapes all < as \< and > as \> avoiding double escaping. Can be disabled by setting NO_ESCAPE_HTML environment variable to "true"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL