From fff8935b9458e63959d60a78ded17f770777f91b Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:26:29 +0400 Subject: [PATCH] core: fix status parsing 2 (#2809) --- src/Simplex/Chat/Messages.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Chat/Messages.hs b/src/Simplex/Chat/Messages.hs index 9e7be62332..1464f6247b 100644 --- a/src/Simplex/Chat/Messages.hs +++ b/src/Simplex/Chat/Messages.hs @@ -553,7 +553,8 @@ instance MsgDirectionI d => StrEncoding (CIFileStatus d) where instance StrEncoding ACIFileStatus where strEncode (AFS _ s) = strEncode s strP = - statusP <|> (AFS SMDSnd . CIFSInvalid . safeDecodeUtf8 <$> A.takeByteString) + (statusP <* A.endOfInput) -- endOfInput to make it fail on partial correct parse + <|> (AFS SMDSnd . CIFSInvalid . safeDecodeUtf8 <$> A.takeByteString) where statusP = A.takeTill (== ' ') >>= \case @@ -669,7 +670,8 @@ instance MsgDirectionI d => StrEncoding (CIStatus d) where instance StrEncoding ACIStatus where strEncode (ACIStatus _ s) = strEncode s strP = - statusP <|> (ACIStatus SMDSnd . CISInvalid . safeDecodeUtf8 <$> A.takeByteString) + (statusP <* A.endOfInput) -- endOfInput to make it fail on partial correct parse, e.g. "snd_rcvd ok complete" + <|> (ACIStatus SMDSnd . CISInvalid . safeDecodeUtf8 <$> A.takeByteString) where statusP = A.takeTill (== ' ') >>= \case