Documentation
¶
Overview ¶
Package ansi provides shared helpers for scanning ECMA-48/ANSI escape sequences. It exists to give the CSI final-byte range a single source of truth: the same [a-zA-Z]-only bug (missing '@', '~', and other non-letter terminators per ECMA-48) was independently reimplemented across the codebase (session/detection, session/detection/ratelimit, session/tmux, server/services, pkg/analytics) before being fixed in BUG-025. Callers should use this package instead of hand-rolling the character class or byte range again — CSIFinalByteClass/StripCSI for regex-based scanners, IsCSIFinalByte for manual byte-level scanners (e.g. pkg/analytics/escape_code_parser.go).
Only the entry points callers actually need are exported; the compiled regex and the raw byte bounds are implementation details of StripCSI and IsCSIFinalByte respectively.
Index ¶
Constants ¶
const CSIFinalByteClass = `[@-~]`
CSIFinalByteClass is the regex character class for a CSI sequence's final byte. Per ECMA-48, CSI final bytes span 0x40-0x7E ('@' through '~'), not just ASCII letters — sequences like Insert Character (CSI Ps @) or tilde-terminated function-key sequences would otherwise be left unstripped, leaking raw escape bytes into text that downstream pattern matching operates on. Exported because callers combining the CSI branch with other alternatives (OSC, charset designation, etc.) need to build their own regexp rather than use the simple csiRegex below — see session/detection/detector.go's ansiStripRegex.
Variables ¶
This section is empty.
Functions ¶
func IsCSIFinalByte ¶
IsCSIFinalByte reports whether b is a valid CSI sequence final byte per ECMA-48 (0x40-0x7E). Byte-level twin of CSIFinalByteClass for parsers that scan byte-by-byte rather than via regexp.
Types ¶
This section is empty.