sanitize

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sanitize supplies immutable HTML fragment allowlists backed by bluemonday. Output is for HTML body content, not scripts, CSS, URLs or attributes.

Index

Constants

View Source
const MaxInputBytes = 1 << 20
View Source
const MaxOutputBytes = 4 << 20

Variables

This section is empty.

Functions

func StripTags

func StripTags(ctx context.Context, input string) (string, error)

StripTags returns escaped HTML text with all tags removed. Active-element content is discarded. Calls share one immutable empty-allowlist policy with the default bounds; it is built on first use.

Types

type Config

type Config struct {
	AllowedTags []string
	InputBytes  int
	OutputBytes int
}

func DefaultConfig

func DefaultConfig() Config

type Policy

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

Policy never exposes the mutable third-party builder. It is safe for concurrent calls after construction. No CSS, event handlers, data attributes, forms, embedded documents, SVG/MathML, data URLs or script-capable tags are admitted.

func New

func New(config Config) (*Policy, error)

func (*Policy) HTML

func (p *Policy) HTML(ctx context.Context, input string) (string, error)

Jump to

Keyboard shortcuts

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