From 98aca70641905000e2104d456c8f24677e31ef75 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 14 Sep 2016 14:46:18 -0400 Subject: fix PoW deserialization --- HTTP.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'HTTP.hs') diff --git a/HTTP.hs b/HTTP.hs index 70d857d..d76a753 100644 --- a/HTTP.hs +++ b/HTTP.hs @@ -93,8 +93,8 @@ instance ToHttpApiData ProofOfWork where <> ":" <> b64 b instance FromHttpApiData ProofOfWork where parseUrlPiece t = do - let (salt, rest) = T.break (/= ':') t - let (hmac, rest') = T.break (/= ':') rest + let (salt, rest) = T.break (== ':') t + let (hmac, rest') = T.break (== ':') (T.drop 1 rest) b <- unb64 (T.drop 1 rest') return $ ProofOfWork b $ RequestID { randomSalt = RandomSalt salt @@ -105,6 +105,7 @@ b64 :: B.ByteString -> Text b64 v = T.decodeUtf8 $ Raaz.toByteString (Raaz.encode v :: Raaz.Base64) unb64 :: Monad m => Text -> m B.ByteString -unb64 t = maybe (fail "bad base64 data") (return . Raaz.decodeFormat) f - where - f = Raaz.fromByteString (T.encodeUtf8 t) :: Maybe Raaz.Base64 +unb64 t = maybe + (fail "bad base64 data") + (return . Raaz.decodeFormat) + (Raaz.fromByteString (T.encodeUtf8 t) :: Maybe Raaz.Base64) -- cgit v1.2.3