html

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package html provides XSS prevention (CWE-79) using pure Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeString

func EscapeString(s string) string

EscapeString escapes HTML special characters.

func UnescapeString

func UnescapeString(s string) string

UnescapeString unescapes HTML entities.

Types

type Sanitizer

type Sanitizer struct {
	// contains filtered or unexported fields
}

Sanitizer provides HTML sanitization.

func New

func New(allowedTags []string) *Sanitizer

New creates an HTML Sanitizer.

func UGC

func UGC() *Sanitizer

UGC returns a sanitizer for User Generated Content.

func (*Sanitizer) AllowedTags

func (s *Sanitizer) AllowedTags() []string

AllowedTags returns the list of allowed tags.

func (*Sanitizer) IsStripAll

func (s *Sanitizer) IsStripAll() bool

IsStripAll returns whether all tags are stripped.

func (*Sanitizer) SanitizeAttribute

func (s *Sanitizer) SanitizeAttribute(input string) string

SanitizeAttribute escapes HTML attribute values.

func (*Sanitizer) SanitizeBody

func (s *Sanitizer) SanitizeBody(input string) string

SanitizeBody removes dangerous HTML elements.

func (*Sanitizer) StripTags

func (s *Sanitizer) StripTags(input string) string

StripTags removes all HTML tags.

Jump to

Keyboard shortcuts

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