pub fn sanitize_message(msg: &str) -> StringExpand description
Sanitize a message by removing dangerous escape sequences and control characters.
- Removes ANSI escape sequences
- Removes OSC sequences (terminal commands)
- Removes CSI sequences
- Removes control characters except \n, \t, \r
- Removes invisible characters (see
is_invisible) and normalises carriage returns (\r\n→\n, a lone\rdropped) — before any content check runs, so the text scanned is the text delivered - Truncates to MAX_MESSAGE_LENGTH with UTF-8 safety