Preserve UTF-8 when truncating input status
This commit is contained in:
committed by
Brandon McGinty
parent
5480dee0fd
commit
cbc6369071
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"git.stormux.org/storm/barnard/gumble/gumble"
|
||||
)
|
||||
@@ -57,6 +58,15 @@ func TestNotificationExpansionIsSinglePassAndNotifyDoesNotBlock(t *testing.T) {
|
||||
// and renderer resources. Cleanup must be safe for repeated disconnects.
|
||||
// Regression: user and channel names in the navigation tree bypassed message
|
||||
// escaping and could still carry terminal control characters.
|
||||
// Regression: status truncation used byte indexes and could create invalid
|
||||
// UTF-8 when a non-ASCII user or channel name exceeded the display limit.
|
||||
func TestTruncateInputStatusPreservesUTF8(t *testing.T) {
|
||||
got := truncateInputStatus(strings.Repeat("é", 21))
|
||||
if !utf8.ValidString(got) || utf8.RuneCountInString(got) != 21 {
|
||||
t.Fatalf("invalid truncation %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTreeItemSanitizesServerNames(t *testing.T) {
|
||||
item := TreeItem{Channel: &gumble.Channel{Name: "\x1b[2Jroom"}}
|
||||
if got := item.String(); got != "#[2Jroom" {
|
||||
|
||||
Reference in New Issue
Block a user