mailbox

package
v0.3.3 Latest Latest
Warning

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

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

Documentation

Overview

Package mailbox owns bounded parsing of RFC 5322 author address lists for DKIM2 From authenticity (Draft-09 Section 11).

The parser accepts the RFC 5322 address-list grammar with the RFC 6854 group update and the RFC 6532 UTF-8 extensions: display names, comments, folding white space, quoted local parts, obsolete dotted phrases and local parts, and groups. It does not decode encoded words, rewrite bytes, or normalize local parts. Obsolete route syntax inside angle addresses and empty list elements are rejected as unsupported. Callers receive the flattened mailbox count and, for exactly one mailbox, its local part and A-label domain.

Index

Constants

View Source
const (
	// MaxValueBytes bounds one unfolded author field value.
	MaxValueBytes = 16 * 1024
)

Variables

This section is empty.

Functions

func ParseAuthor

func ParseAuthor(value []byte) (Author, Status)

ParseAuthor parses one unfolded From field value and classifies it. Only StatusSingle returns a usable Author.

Types

type Author

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

Author is the single parsed author mailbox.

func (Author) ASCII

func (a Author) ASCII() bool

ASCII reports whether the written local part and domain were pure ASCII.

func (Author) Domain

func (a Author) Domain() string

Domain returns the lowercase A-label DNS domain.

func (Author) InGroup

func (a Author) InGroup() bool

InGroup reports whether the mailbox was written inside RFC 6854 group syntax.

func (Author) LocalPart

func (a Author) LocalPart() string

LocalPart returns the local part exactly as written, including quotes.

type Status

type Status string

Status classifies one author field value.

const (
	// StatusSingle reports exactly one mailbox with a DNS domain.
	StatusSingle Status = "single"
	// StatusMalformed reports syntax outside the supported grammar.
	StatusMalformed Status = "malformed"
	// StatusNoMailbox reports a syntactically valid value without any mailbox,
	// such as an empty group.
	StatusNoMailbox Status = "no_mailbox"
	// StatusMultiple reports more than one mailbox after flattening groups.
	StatusMultiple Status = "multiple"
	// StatusDomainLiteral reports a single mailbox whose domain is a literal.
	StatusDomainLiteral Status = "domain_literal"
	// StatusInvalidDomain reports a single mailbox whose domain is not a valid
	// IDNA2008 DNS name.
	StatusInvalidDomain Status = "invalid_domain"
)

Jump to

Keyboard shortcuts

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