Documentation
¶
Overview ¶
Package tomllimit rejects pathologically nested TOML before it reaches a decoder. The decoder in use (BurntSushi/toml) spends memory that grows far faster than the input as nesting deepens — a 24 KB document nested a few thousand levels deep allocates over a gigabyte — and that work happens inside the decoder, below any memory accounting, so a memory limit cannot stop it. A cheap single pass over the source caps the nesting depth first.
Index ¶
Constants ¶
const MaxDepth = 100
MaxDepth is the deepest nesting any TOML document given to a decoder may have. Real configuration files nest a handful of levels; at this depth the decoder's memory stays at baseline, far below the catastrophic range.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check reports an *ErrTooDeep when src nests deeper than MaxDepth, in any of the ways TOML nests: inline tables and arrays (`{` / `[` in a value), and dotted keys and table headers (`a.b.c = 1`, `[a.b.c]`). It is a single linear scan that respects strings (basic, literal and their multi-line forms) and comments, so brackets and dots inside them are not counted.
Types ¶
type ErrTooDeep ¶
type ErrTooDeep struct{ Max int }
ErrTooDeep is returned when a document nests deeper than the cap.
func (ErrTooDeep) Error ¶
func (e ErrTooDeep) Error() string