summaryrefslogtreecommitdiffstats
path: root/Codec/MIME/QuotedPrintable.hs
diff options
context:
space:
mode:
authorSigbjorn Finne <sof@galois.com>2008-09-19 09:55:01 -0700
committerSigbjorn Finne <sof@galois.com>2008-09-19 09:55:01 -0700
commit3bc46d19146c73a7984bacb2b8685989b6a4b2da (patch)
tree8fdaae862b0493121bd2deace35d0ac01cd85775 /Codec/MIME/QuotedPrintable.hs
parent7567f36fdfc9f6416bba4db23e4f9bbdcf874dff (diff)
fix terrible QP encoding snafu + tidyups
Diffstat (limited to 'Codec/MIME/QuotedPrintable.hs')
-rw-r--r--Codec/MIME/QuotedPrintable.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/Codec/MIME/QuotedPrintable.hs b/Codec/MIME/QuotedPrintable.hs
index a6dc99a..ec57ba5 100644
--- a/Codec/MIME/QuotedPrintable.hs
+++ b/Codec/MIME/QuotedPrintable.hs
@@ -4,7 +4,7 @@
-- Copyright : (c) Galois, Inc. 2008
-- License : BSD3
--
--- Maintainer:
+-- Maintainer: Sigbjorn Finne <sof@galois.com>
-- Stability : provisional
-- Portability:
--
@@ -42,14 +42,14 @@ encodeLength :: Int -> String -> String
encodeLength _ "" = ""
encodeLength n (x:xs)
| n >= 72 = '=':'\r':'\n':encodeLength 0 (x:xs)
-encodeLength n ('=':xs)
+encodeLength _ ('=':xs)
= '=':'3':'D':encodeLength 0 xs
encodeLength n (x:xs)
| ox >= 0x100 = error ("QuotedPrintable.encode: encountered > 8 bit character: " ++ show (x,ox))
| n >= 72 = '=':'\r':'\n':encodeLength 0 (x:xs)
| ox >= 0x21 && ox <= 0x7e = x : encodeLength (n+1) xs
| ox == 0x09 || ox == 0x20 = x : encodeLength (n+1) xs
- | otherwise = '=':'\r':'\n':encodeLength 0 (x:xs)
+ | otherwise = '=':showH (ox `div` 0x10): showH (ox `mod` 0x10):encodeLength (n+3) xs
where
ox = ord x
showH v