summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-10-07 13:08:51 +0200
committertv <tv@krebsco.de>2020-11-17 21:08:21 +0100
commit29749366052a8f6c05b314f1ff17201717855ad7 (patch)
treeb4ee882f7585a2545f3119e8fb430a5b180f9915 /src
parentf18d08d08ca5863e19135cc2b759389a8d07ec3b (diff)
Much.ParseMail.encodeWord: reference RFC 2047v1.3.0
Diffstat (limited to 'src')
-rw-r--r--src/Much/ParseMail.hs12
1 files 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