summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-10-08 12:42:40 +0200
committerdelthas <delthas@dille.cc>2022-10-08 12:45:00 +0200
commit700139404044730a726af7cd57e3d2dbc07871ea (patch)
tree4e9fd05309d909da1c5a16828e21da32edc53ca1
parentPrevnet highlighting on notices, drop unknown CTCP (diff)
Replace non-UTF8 chars with the Unicode replacement character
tcell does not handle non-UTF8 chars well, so we explicitly replace them when getting the messages to avoid passing them to tcell down the line.
-rw-r--r--irc/channel.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/irc/channel.go b/irc/channel.go
index c4a9e6f..b318784 100644
--- a/irc/channel.go
+++ b/irc/channel.go
@@ -4,6 +4,8 @@ import (
"bufio"
"fmt"
"net"
+ "strings"
+ "unicode"
)
const chanCapacity = 64
@@ -16,6 +18,7 @@ func ChanInOut(conn net.Conn) (in <-chan Message, out chan<- Message) {
r := bufio.NewScanner(conn)
for r.Scan() {
line := r.Text()
+ line = strings.ToValidUTF8(line, string([]rune{unicode.ReplacementChar}))
msg, err := ParseMessage(line)
if err != nil {
continue