htmllimits

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package htmllimits holds the size limits applied when rendering HTML, such as maximum image and stylesheet sizes. Limits guard against inputs large enough to exhaust memory.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImageTooLarge      = errors.New("html: image exceeds configured limits")
	ErrDOMTooDeep         = errors.New("html: DOM exceeds configured depth limit")
	ErrDOMTooLarge        = errors.New("html: DOM exceeds configured node limit")
	ErrSVGTooLarge        = errors.New("html: SVG raster dimensions exceed configured pixel limit")
	ErrStyleRulesTooLarge = errors.New("html: stylesheet exceeds configured rule limit")
)

Errors reported when HTML input goes past one of the configured limits.

Functions

func Int64Exceeded

func Int64Exceeded(limit, value int64) bool

Int64Exceeded reports whether value is over limit. A limit of zero or less is treated as no limit.

func IntExceeded

func IntExceeded(limit, value int) bool

IntExceeded reports whether value is over limit. A limit of zero or less is treated as no limit.

Types

type Limits

type Limits struct {
	MaxImagePixels int64
	MaxImageBytes  int64
	MaxDOMDepth    int
	MaxDOMNodes    int
	MaxSVGPixels   int64
	MaxStyleRules  int
}

Limits caps how much work one HTML document may cost. A zero field means "use the default"; a negative field turns that limit off.

func Default

func Default() Limits

Default returns the limits used when the caller does not set any.

func NoLimits

func NoLimits() Limits

NoLimits returns limits with every check turned off.

func Normalize

func Normalize(l Limits) Limits

Normalize fills in each unset (zero) field of l with the default for that limit and returns the result.

Jump to

Keyboard shortcuts

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