summaryrefslogtreecommitdiffhomepage
path: root/HTTP.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-14 14:46:18 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-14 14:46:18 -0400
commit98aca70641905000e2104d456c8f24677e31ef75 (patch)
tree7853dda9d1029898d4a9e7a6d15412fb04139f1b /HTTP.hs
parent98636bf2b43fed264a541974a058cb0003e81139 (diff)
downloadkeysafe-98aca70641905000e2104d456c8f24677e31ef75.tar.gz
fix PoW deserialization
Diffstat (limited to 'HTTP.hs')
-rw-r--r--HTTP.hs11
1 files changed, 6 insertions, 5 deletions
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)