Skip to main content

strip_vt_sequences

Function strip_vt_sequences 

Source
pub fn strip_vt_sequences(text: &str) -> String
Expand description

Strip VT/ANSI escape sequences from text before PTY injection.

Removes CSI (ESC[), OSC (ESC]), DCS (ESC P), APC (ESC _), PM (ESC ^), SOS (ESC X) sequences, and bare two-byte ESC x sequences. Printable characters and newlines are passed through.

This is required for safe WriteText dispatch: a script must not be able to embed control sequences that reposition the cursor, exfiltrate data, or otherwise corrupt the terminal state.