From 29749366052a8f6c05b314f1ff17201717855ad7 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 7 Oct 2020 13:08:51 +0200 Subject: Much.ParseMail.encodeWord: reference RFC 2047 --- src/Much/ParseMail.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Much/ParseMail.hs b/src/Much/ParseMail.hs index e12737a..d9bb733 100644 --- a/src/Much/ParseMail.hs +++ b/src/Much/ParseMail.hs @@ -281,11 +281,15 @@ encodedWord = return $ T.decodeUtf8 $ BS8.pack - $ QP.decode - -- ^ TODO this current doesn't decode - -- underscore to space - $ map (\c -> if c == '_' then ' ' else c) + $ decodeQ $ w + where + -- RFC 2047, 4.2. The "Q" encoding + decodeQ = + QP.decode . replace '_' ' ' + + replace a b = + map $ \c -> if c == a then b else c -- word = encoded-word / atom / quoted-string -- cgit v1.2.3