diff options
author | Raúl Benencia <rul@kalgan.cc> | 2013-08-30 15:26:33 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2013-08-30 15:26:33 -0300 |
commit | 58836f3c2020c634a2a508846140d163572fd5c0 (patch) | |
tree | 13a52943928f65a506201f06199dba1e403a7a93 /Print.hs | |
parent | 4010acf611b862be18e4a5fc8964f38c7767e5f2 (diff) |
Fix problem with multi-lines subjects
Diffstat (limited to 'Print.hs')
-rw-r--r-- | Print.hs | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -8,24 +8,29 @@ module Print where +import Data.Char (isSpace) +import Data.List (intercalate) import Network.Email.Mailbox(Flag(..), Flags) import Text.ParserCombinators.Parsec.Rfc2822(NameAddr(..)) -import Data.Char ( isSpace ) import Email import Rfc1342 nameLen = 20 -ppNameAddr nas = concat $ map ppNameAddr' nas +ppNameAddr nas = intercalate ", " $ map ppNameAddr' nas where ppNameAddr' na = case nameAddr_name na of Nothing -> nameAddr_addr na - Just n -> decodeField n + Just n -> (decodeField n) ++ " <" ++ nameAddr_addr na ++ ">" -ppIndexNameAddr = normalizeLen nameLen . ppNameAddr +ppIndexNameAddr nas = normalizeLen nameLen $ concat $ map ppNameAddr' nas + where ppNameAddr' na = case nameAddr_name na of + Nothing -> nameAddr_addr na + Just n -> (decodeField n) subjectLen = 90 -ppSubject = decodeField -ppIndexSubject = normalizeLen subjectLen . ppSubject +ppSubject = flat . decodeField + +flat xs = intercalate " " $ map (dropWhile isSpace) $ map (filter (/= '\r')) $ lines xs ppFlags :: Flags -> String ppFlags = map ppFlag |