From 64515e2c666067953e3a9680b4f0db84f3838498 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Tue, 8 Aug 2023 00:54:24 -0400 Subject: Fix replies to messages with non-ASCII characters --- xmpp/handlers.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'xmpp') diff --git a/xmpp/handlers.go b/xmpp/handlers.go index e85dfc9..36f9cf9 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -149,7 +149,12 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) { "end": body.End, }).Warn(errors.Wrap(err, "Failed to parse fallback end!")) } - text = text[:start] + text[end:] + + fullRunes := []rune(text) + cutRunes := make([]rune, 0, len(text)-int(end-start)) + cutRunes = append(cutRunes, fullRunes[:start]...) + cutRunes = append(cutRunes, fullRunes[end:]...) + text = string(cutRunes) } } var replaceId int64 -- cgit v1.2.3