(text: string)
| 29 | * C0 control characters, so rendering can never crash the TUI. |
| 30 | */ |
| 31 | export function sanitizeShellOutput(text: string): string { |
| 32 | if (typeof text !== 'string') return ''; |
| 33 | if (text.length === 0) return text; |
| 34 | try { |
| 35 | return text |
| 36 | .replace(OSC_PATTERN, '') |
| 37 | .replace(CSI_PATTERN, '') |
| 38 | .replace(ESC_SINGLE_PATTERN, '') |
| 39 | .replace(C0_CONTROL_PATTERN, ''); |
| 40 | } catch { |
| 41 | return text.replace(C0_CONTROL_PATTERN, ''); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Format captured stdout/stderr for the transcript. Sanitizes both streams and |
no outgoing calls
no test coverage detected