From 58836f3c2020c634a2a508846140d163572fd5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Fri, 30 Aug 2013 15:26:33 -0300 Subject: Fix problem with multi-lines subjects --- Print.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Print.hs') diff --git a/Print.hs b/Print.hs index 4b62619..1e46c00 100644 --- a/Print.hs +++ b/Print.hs @@ -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 -- cgit v1.2.3