SanitizeTerminalLine is SanitizeTerminal for values rendered as a single line or table cell (process names, command lines, env entries, paths). SanitizeTerminal intentionally preserves \n and \t for multi-line layout; in a single-line field those let an embedded value forge extra output lines or shi
(s string)
| 74 | // single-line field those let an embedded value forge extra output lines or |
| 75 | // shift columns, so they are escaped here too. |
| 76 | func SanitizeTerminalLine(s string) string { |
| 77 | if strings.ContainsAny(s, "\n\t") { |
| 78 | s = strings.NewReplacer("\n", `\n`, "\t", `\t`).Replace(s) |
| 79 | } |
| 80 | return SanitizeTerminal(s) |
| 81 | } |
| 82 | |
| 83 | func appendEscapedByte(b *strings.Builder, bt byte) { |
| 84 | b.WriteString(`\x`) |