vtcode_config/constants/ansi.rs
1//! ANSI escape sequence parsing constants
2//!
3//! These constants prevent infinite loops when parsing malformed ANSI sequences.
4//! See: https://github.com/anthropics/claude-code/issues/22094
5
6/// Maximum length for OSC/DCS/PM/APC/SOS escape sequences before bailing out.
7/// OSC sequences rarely exceed 4KB in practice (e.g., hyperlinks, window titles).
8/// This guard prevents CPU spinning on malformed input.
9pub const ANSI_MAX_ESCAPE_SEQ_LENGTH: usize = 4096;
10
11/// Maximum parameter length for CSI sequences (e.g., ESC[...m).
12/// CSI parameters are typically short numeric values separated by semicolons.
13pub const ANSI_MAX_CSI_PARAM_LENGTH: usize = 20;