X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FMIMEParams.hs;fp=Network%2FHTTP%2FLucu%2FMIMEParams.hs;h=6f9eb7e1b8a9f4055b0bc878578d6b2679952991;hp=88dbb6fdd71a47bdc832cca03dc4b36797f3230b;hb=c9a269666f2d60d9c5ba817e1c43b45f6d77de22;hpb=bc7c6c8fc24ca3c35cea6007d87df8e6a5fd1240 diff --git a/Network/HTTP/Lucu/MIMEParams.hs b/Network/HTTP/Lucu/MIMEParams.hs index 88dbb6f..6f9eb7e 100644 --- a/Network/HTTP/Lucu/MIMEParams.hs +++ b/Network/HTTP/Lucu/MIMEParams.hs @@ -168,7 +168,7 @@ paramP = do skipMany lws return $ AsciiParam name sect payload nameP ∷ Parser (CIAscii, Integer, Bool) -nameP = do name ← (A.toCIAscii ∘ A.unsafeFromByteString) <$> +nameP = do name ← (cs ∘ A.unsafeFromByteString) <$> takeWhile1 (\c → isToken c ∧ c ≢ '*') sect ← option 0 $ try (char '*' *> decimal ) isEncoded ← option False $ try (char '*' *> pure True) @@ -190,7 +190,7 @@ initialEncodedValue return (charset, payload) where metadata ∷ Parser CIAscii - metadata = (A.toCIAscii ∘ A.unsafeFromByteString) <$> + metadata = (cs ∘ A.unsafeFromByteString) <$> takeWhile (\c → c ≢ '\'' ∧ isToken c) encodedPayload ∷ Parser BS.ByteString @@ -257,7 +257,7 @@ sortBySection = flip go (∅) → fail (concat [ "Duplicate section " , show $ section x , " for parameter '" - , A.toString $ A.fromCIAscii $ epName x + , cs $ epName x , "'" ]) @@ -280,7 +280,7 @@ decodeSections = (decodeSeq =≪) ∘ flip (flip toSeq 0) (∅) → fail (concat [ "Missing section " , show $ section p , " for parameter '" - , A.toString $ A.fromCIAscii $ epName p + , cs $ epName p , "'" ]) @@ -296,9 +296,7 @@ decodeSections = (decodeSeq =≪) ∘ flip (flip toSeq 0) (∅) Just (ContinuedEncodedParam {..}, _) → fail "decodeSeq: internal error: CEP at section 0" Just (AsciiParam {..}, xs) - → let t = A.toText apPayload - in - decodeSeq' Nothing xs $ singleton t + → decodeSeq' Nothing xs $ singleton $ cs apPayload decodeSeq' ∷ Monad m ⇒ Maybe Decoder @@ -320,13 +318,11 @@ decodeSections = (decodeSeq =≪) ∘ flip (flip toSeq 0) (∅) → fail (concat [ "Section " , show epSection , " for parameter '" - , A.toString $ A.fromCIAscii epName + , cs epName , "' is encoded but its first section is not" ]) Just (AsciiParam {..}, xs) - → let t = A.toText apPayload - in - decodeSeq' decoder xs $ chunks ⊳ t + → decodeSeq' decoder xs $ chunks ⊳ cs apPayload type Decoder = BS.ByteString → Either UnicodeException Text @@ -340,5 +336,4 @@ getDecoder ∷ Monad m ⇒ CIAscii → m Decoder getDecoder charset | charset ≡ "UTF-8" = return decodeUtf8' | charset ≡ "US-ASCII" = return decodeUtf8' - | otherwise = fail $ "No decoders found for charset: " - ⧺ A.toString (A.fromCIAscii charset) + | otherwise = fail $ "No decoders found for charset: " ⊕ cs charset