aboutsummaryrefslogtreecommitdiff
path: root/Print.hs
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2013-08-30 15:26:33 -0300
committerRaúl Benencia <rul@kalgan.cc>2013-08-30 15:26:33 -0300
commit58836f3c2020c634a2a508846140d163572fd5c0 (patch)
tree13a52943928f65a506201f06199dba1e403a7a93 /Print.hs
parent4010acf611b862be18e4a5fc8964f38c7767e5f2 (diff)
Fix problem with multi-lines subjects
Diffstat (limited to 'Print.hs')
-rw-r--r--Print.hs17
1 files changed, 11 insertions, 6 deletions
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
nihil fit ex nihilo