Sanitize terminal widget text

This commit is contained in:
Brandon McGinty (chatgpt)
2026-08-09 23:54:49 -04:00
committed by Brandon McGinty
parent 8348a7083d
commit 770635955a
6 changed files with 26 additions and 4 deletions
+11
View File
@@ -32,3 +32,14 @@ func TestCloseIsNonblockingAndIdempotent(t *testing.T) {
t.Fatal("Close did not signal shutdown")
}
}
func TestSafeRuneRemovesTerminalControlCharacters(t *testing.T) {
for _, r := range []rune{'\x1b', '\x7f', '\u202e'} {
if got := safeRune(r); got != ' ' {
t.Errorf("safeRune(%U) = %U, want space", r, got)
}
}
if got := safeRune('A'); got != 'A' {
t.Fatalf("safeRune altered printable text: %U", got)
}
}