Documentation
¶
Overview ¶
Package textsafe validates input text and sanitizes terminal and log output.
Index ¶
Constants ¶
const ( // MaxTitleRunes is the maximum number of Unicode code points in a title. MaxTitleRunes = 500 // MaxNotesBytes is the maximum UTF-8 byte length of normalized notes. // AIDEV-NOTE: Change markdown.maxNoteBytes with this limit so the // pre-render guard matches validation. MaxNotesBytes = 65536 )
Variables ¶
This section is empty.
Functions ¶
func Sanitize ¶
Sanitize replaces unsafe runes and each invalid UTF-8 byte with U+FFFD. It preserves graphic runes, newlines, tabs, ZWNJ, and ZWJ for terminal/log output.
func SanitizeLine ¶
SanitizeLine sanitizes s and also replaces newlines and tabs with U+FFFD.
func Truncate ¶
Truncate shortens s to width terminal cells, including tail when truncated, while preserving grapheme clusters and ANSI sequences. It does not sanitize s.
func ValidateName ¶
ValidateName checks that s contains 1..maxLen ASCII letters, digits, dots, underscores, or hyphens, without trimming or otherwise normalizing it.
func ValidateNotes ¶
ValidateNotes strips one leading BOM, converts CRLF and CR to LF, and validates notes of at most MaxNotesBytes bytes. Empty notes are valid.
func ValidateTitle ¶
ValidateTitle strips one leading BOM, trims whitespace, and validates a nonempty, single-line title of at most MaxTitleRunes Unicode code points.
Types ¶
This section is empty.