From 1d98a7613ecd493a236e3973c65fff44fff8eba3 Mon Sep 17 00:00:00 2001 From: CptSaulGoodman <35928982+MiDoTr@users.noreply.github.com> Date: Tue, 13 May 2025 12:47:41 +0200 Subject: [PATCH] Fix: message.MessageContent can have special characters which breaks saving to csv. -> Need to utf-8 encode Signed-off-by: CptSaulGoodman <35928982+MiDoTr@users.noreply.github.com> --- src/pkg/utils/chat_storage.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pkg/utils/chat_storage.go b/src/pkg/utils/chat_storage.go index 734f583..306ecd7 100644 --- a/src/pkg/utils/chat_storage.go +++ b/src/pkg/utils/chat_storage.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "sync" + "net/url" "github.com/aldinokemal/go-whatsapp-web-multidevice/config" ) @@ -79,7 +80,9 @@ func RecordMessage(messageID string, senderJID string, messageContent string) er } // Prepare the new record - newRecord := []string{message.MessageID, message.JID, message.MessageContent} + // Fix: message.MessageContent can have special characters which breaks saving to csv. -> Need to utf-8 encode + encodedMessageContent := url.QueryEscape(message.MessageContent) + newRecord := []string{message.MessageID, message.JID, encodedMessageContent} records = append([][]string{newRecord}, records...) // Prepend new message // Write all records back to file