Documentation
¶
Overview ¶
Package yamlsafe provides a typed YAML scalar that safely round-trips through plain-style YAML emission. Using the Scalar type prevents callers from passing raw user input directly into scaffold templates where YAML-meta characters (colon, braces, quotes, newlines, etc.) would break YAML structure or allow injection of adjacent fields.
Usage ¶
s := yamlsafe.Quote(userInput) // always safe to embed in a YAML value fmt.Fprintf(w, "id: %s\n", s) // Scalar.String() returns the quoted form
AI-Hard contract ¶
Quote is the single funnel for YAML scalar quoting in scaffold templates. Direct string interpolation into YAML templates is statically detected by archtest SCAFFOLD-WRITE-FUNNEL-01 (path safety) and YAML-QUOTE-FUNNEL-01 (every yamlsafe.Scalar(...) type conversion outside this package must have a yamlsafe.Quote(...) call as its argument).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scalar ¶
type Scalar string
Scalar is a typed YAML scalar that safely round-trips through plain-style YAML emission. Use Quote to construct from raw user input; the type system then prevents callers from passing raw strings to scaffold templates.
func Quote ¶
Quote constructs a Scalar from raw user input. If raw contains characters that cannot safely render as plain-style YAML (newline / NUL / other C0 / DEL / leading whitespace / : { } [ ] , & * # ? | > ! % @ ` " '), the result is single-quoted with embedded single quotes doubled. Strings containing C0/DEL control characters (except TAB) use double-quoted form with escape sequences so they round-trip correctly through yaml.Unmarshal.
This is the single funnel for YAML scalar quoting in scaffold templates.