From 9969606432d0f2e360ffd138478c5d138fd52860 Mon Sep 17 00:00:00 2001 From: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:30:00 +0400 Subject: [PATCH] fix utf8 encoding when writing to database --- src/Simplex/Chat/Messages.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Simplex/Chat/Messages.hs b/src/Simplex/Chat/Messages.hs index 166ceb340d..edf42d265e 100644 --- a/src/Simplex/Chat/Messages.hs +++ b/src/Simplex/Chat/Messages.hs @@ -35,6 +35,7 @@ import Simplex.Messaging.Agent.Store.SQLite (fromTextField_) import Simplex.Messaging.Encoding.String import Simplex.Messaging.Parsers (dropPrefix, enumJSON, sumTypeJSON) import Simplex.Messaging.Protocol (MsgBody) +import Simplex.Chat.Util (safeDecodeUtf8) data ChatType = CTDirect | CTGroup | CTContactRequest deriving (Show, Generic) @@ -215,7 +216,7 @@ ciContentToText = \case CIRcvFileInvitation RcvFileTransfer {fileInvitation = FileInvitation {fileName}} -> "file " <> T.pack fileName instance ToField (CIContent d) where - toField = toField . decodeLatin1 . LB.toStrict . J.encode + toField = toField . safeDecodeUtf8 . LB.toStrict . J.encode instance ToJSON (CIContent d) where toJSON = J.toJSON . jsonCIContent