From 1a10c09d6150dbc9e8a1718b710252cb7b38b776 Mon Sep 17 00:00:00 2001 From: Cypher Date: Tue, 3 May 2022 15:05:40 -0500 Subject: use stack lts-18.8 Update text handling to keep uptodate with changes with string conversion, using 'encodeUtf' and 'decodeUtf' where necessary. One update uses an odd encoding to and from JSON, which must be looked at later. --- src/Ssb/Feed.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Ssb/Feed.hs') diff --git a/src/Ssb/Feed.hs b/src/Ssb/Feed.hs index f4e96c2..ebdd2f4 100644 --- a/src/Ssb/Feed.hs +++ b/src/Ssb/Feed.hs @@ -72,7 +72,7 @@ extractMessageID (MessageID buf) = buf -- Format of '%[base64 messageId].sha256', the '.sha256' is appended for -- forward compatibility, and is currently assumed. formatMessageID :: MessageID -> Text -formatMessageID (MessageID buf) = "%" <> toS (Base64.encode buf) <> ".sha256" +formatMessageID (MessageID buf) = "%" <> decodeUtf8 (Base64.encode buf) <> ".sha256" -- | TODO: make safe parseMessageID :: Text -> Either Text MessageID @@ -80,7 +80,7 @@ parseMessageID arg = decode $ T.dropEnd constLen $ T.drop 1 arg where constLen = T.length ".sha256" decode :: Text -> Either Text MessageID - decode = mapRight MessageID . mapLeft toS . Base64.decode . toS + decode = mapRight MessageID . mapLeft toS . Base64.decode . encodeUtf8 instance FromJSON MessageID where parseJSON = Aeson.withText "MessageID" $ \v -> case parseMessageID v of @@ -115,14 +115,14 @@ extractSignature :: Signature -> ByteString extractSignature (Signature buf) = buf formatSignature :: Signature -> Text -formatSignature (Signature buf) = toS (Base64.encode buf) <> ".sig.ed25519" +formatSignature (Signature buf) = decodeUtf8 (Base64.encode buf) <> ".sig.ed25519" parseSignature :: Text -> Either Text Signature parseSignature txt = decode $ T.dropEnd constLen txt where constLen = T.length ".sig.ed25519" decode :: Text -> Either Text Signature - decode = mapRight Signature . mapLeft toS . Base64.decode . toS + decode = mapRight Signature . mapLeft toS . Base64.decode . encodeUtf8 instance FromJSON Signature where parseJSON = Aeson.withText "Signature" $ \v -> case parseSignature v of @@ -206,7 +206,7 @@ withSignature signature buf = (dropEnd (BS.length endTxt) buf) <> sigTxt sigTxt = ",\n \"signature\": " <> "\"" - <> toS (formatSignature signature) + <> encodeUtf8 (formatSignature signature) <> "\"" <> endTxt endTxt = "\n}" @@ -332,9 +332,9 @@ encodeForSigning contentOrder arg = do then return (error "external V8 byte string encoder not initialized") else do - atomically $ putTMVar v8Input (cmd <> toS arg) + atomically $ putTMVar v8Input (cmd <> arg) ret <- atomically $ takeTMVar v8Output - let ret' = Base64.decode (toS ret) + let ret' = Base64.decode ret return $ mapLeft toS ret' where cmd = if contentOrder -- cgit v1.2.3