plist

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package plist wraps XML and binary property-list encoding and bounded decoding.

Design

Marshal, Unmarshal, format detection and Decoder centralize use of github.com/micromdm/plist. Untrusted input can be bounded by bytes and XML nesting depth before codec dispatch. The depth control is specific to XML; the byte limit also applies to binary input.

MessageType and RequestType dispatch belong to mdmprotocol/mdm. Using one codec wrapper keeps format and resource-limit choices consistent across protocol callers.

References

Index

Constants

View Source
const (
	DefaultMaxBytes = 4 << 20
	DefaultMaxDepth = 64
)

Defaults applied by Unmarshal. Apple devices send command results of a few hundred KB at most (large inventories); 4 MiB leaves headroom.

Variables

View Source
var (
	ErrTooLarge      = errors.New("plist: input exceeds size limit")
	ErrTooDeep       = errors.New("plist: nesting exceeds depth limit")
	ErrUnknownFormat = errors.New("plist: input is neither XML nor binary plist")
)

Errors returned by the decoders.

Functions

func Marshal

func Marshal(v any) ([]byte, error)

Marshal encodes v as an XML plist.

func MarshalIndent

func MarshalIndent(v any, indent string) ([]byte, error)

MarshalIndent encodes v as an indented XML plist.

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal decodes an XML or binary plist with the default limits.

Types

type Decoder

type Decoder struct {
	MaxBytes int
	MaxDepth int
}

Decoder decodes with explicit limits. Zero values mean the defaults; a negative value disables that limit.

func (Decoder) Unmarshal

func (d Decoder) Unmarshal(data []byte, v any) error

Unmarshal decodes data into v after checking the limits.

type Format

type Format int

Format is the detected plist serialisation.

const (
	FormatUnknown Format = iota
	FormatXML
	FormatBinary
)

Formats.

func DetectFormat

func DetectFormat(data []byte) Format

DetectFormat inspects the first bytes of data.

func (Format) String

func (f Format) String() string

String implements fmt.Stringer.

type Marshaler

type Marshaler = mplist.Marshaler

Marshaler and Unmarshaler are re-exported so callers do not import the underlying library.

type Unmarshaler

type Unmarshaler = mplist.Unmarshaler

Marshaler and Unmarshaler are re-exported so callers do not import the underlying library.

Jump to

Keyboard shortcuts

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