nesting

package
v1.12.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package nesting measures how deeply CUE source nests before it is parsed. CUE's parser recurses once per level with no limit, and a deep enough source overflows the stack, which is fatal to the process: no recover catches it.

Index

Constants

View Source
const MaxDepth = 1000

MaxDepth is the deepest nesting CUE source handed to the parser may have. Shipped definitions nest at most 18 levels; at about 3 KB of stack a level, this costs a few megabytes.

Variables

This section is empty.

Functions

func Check

func Check(src string, max int) error

Check refuses src when it nests deeper than max, or chains more than chainFactor times max operations in one expression.

func CheckJSONStrings

func CheckJSONStrings(raw []byte, max int) error

CheckJSONStrings refuses a JSON document any of whose strings nests deeper than max as CUE, naming the first such field. It is for objects, such as definitions, that carry CUE in their string fields. A document that does not decode is left to the caller's decoder to report.

func Depth

func Depth(src string) int

Depth is the deepest nesting of src: braces, brackets, parentheses, string interpolations, chained labels (a: b: c: nests a struct per label after the first) and prefix operators, as the parser recurses through them. Strings and comments do not count.

Types

This section is empty.

Jump to

Keyboard shortcuts

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