Neutralize an attacker-supplied WebSocket message before embedding it in a log line:
JSON.stringify escapes CR/LF, ANSI escape sequences, and every other control character (so a
frame cannot forge log entries or corrupt terminal output), and truncation keeps a multi-megabyte
frame from bloating the log. Mirrors the CR/LF-avoidance rationale in handle-route.ts. Exported
for direct unit testing.
Neutralize an attacker-supplied WebSocket message before embedding it in a log line:
JSON.stringifyescapes CR/LF, ANSI escape sequences, and every other control character (so a frame cannot forge log entries or corrupt terminal output), and truncation keeps a multi-megabyte frame from bloating the log. Mirrors the CR/LF-avoidance rationale inhandle-route.ts. Exported for direct unit testing.