__color__	__group__	ticket	summary	component	version	type	owner	status	created	_changetime	_description	_reporter
3	 Release	3	comments are lost	component1		defect	somebody	new	2010-02-03T21:22:44Z+0000	2010-02-03T21:22:44Z+0000	"Maciej Piechotka <uzytkownik2@gmail.com> says:

{{{
ghci> let ([h], Nothing) = parse_headers ""Message-ID:
example@example.com (test)""
ghci> h
Header {h_raw_header = [""Message-ID: example@example.com (test)""],
h_raw_name = ""Message-ID:"", h_name = ""message-id:"", h_body = ""
example@example.com ()""}

shouldn't it be:

Header {h_raw_header = [""Message-ID: example@example.com (test)""],
h_raw_name = ""Message-ID:"", h_name = ""message-id:"", h_raw_body = ""
example@example.com (test)"", h_body = "" example@example.com ""}
}}}
"	igloo
3	 Release	1	parse problem with whitespace in comments	component1		defect	somebody	new	2010-02-03T21:18:59Z+0000	2010-02-03T21:18:59Z+0000	"Satoshi Nakamura <snak@snak.org> reported:

{{{
I've been using mime-string-0.3 to parse mime message and found that when
MIME-Version contains a comment which contains white-space it failed to
parse. I looked into the source code and found that it uses p_NO_WS_CTL
where it should use p_FWS. I think the attached patch solve this problem.
}}}

{{{
diff -ur mime-string-0.3.orig/Codec/MIME/String/Headers.hs mime-string-0.3/Codec/MIME/String/Headers.hs
--- mime-string-0.3.orig/Codec/MIME/String/Headers.hs   2007-03-29 22:06:31.000000000 +0900
+++ mime-string-0.3/Codec/MIME/String/Headers.hs        2007-12-17 12:44:49.000000000 +0900
@@ -151,8 +151,8 @@
 p_comment :: Parser Char ()
 p_comment = ()
         <$  pChar '('
-        <*  pMany (() <$  pMany p_NO_WS_CTL <*  p_ccontent)
-        <*  pMany p_NO_WS_CTL
+        <*  pMany (() <$  p_FWS <*  p_ccontent)
+        <*  p_FWS
         <*  pChar ')'
 
 -- We might want to keep the result. If we do then we also need to
}}}
"	igloo
3	 Release	2	use dataenc instead of base64-string	component1		defect	somebody	new	2010-02-03T21:21:35Z+0000	2010-02-03T21:21:35Z+0000	"Magnus Therning <magnus@therning.org> said:

{{{
I've attached a patch against version 0.4 of mime-string.  It replaces
the use of base64-string with the use of dataenc.

Do with it what you like :-)

If you like the idea, but not my code, then let me know how I can
improve it.
}}}

{{{
diff -u --recursive mime-string-0.4/Codec/MIME/String/EncodedWord.hs mime-string-0.4_modified/Codec/MIME/String/EncodedWord.hs
--- mime-string-0.4/Codec/MIME/String/EncodedWord.hs    2008-12-05 18:42:47.000000000 +0000
+++ mime-string-0.4_modified/Codec/MIME/String/EncodedWord.hs   2009-03-05 00:12:41.000000000 +0000
@@ -1,8 +1,9 @@

 module Codec.MIME.String.EncodedWord (base64_encode) where

-import Codec.Binary.Base64.String (encode)
+import Data.Char (ord)
+import Codec.Binary.Base64 (encode)

 base64_encode :: String -> String -> String
-base64_encode charset xs = ""=?"" ++ charset ++ ""?B?"" ++ encode xs ++ ""?=""
-
+base64_encode charset xs = ""=?"" ++ charset ++ ""?B?"" ++ encode ws ++ ""?=""
+    where ws = map (fromIntegral . ord) xs
diff -u --recursive mime-string-0.4/Codec/MIME/String/Flatten.hs mime-string-0.4_modified/Codec/MIME/String/Flatten.hs
--- mime-string-0.4/Codec/MIME/String/Flatten.hs    2008-12-05 18:42:47.000000000 +0000
+++ mime-string-0.4_modified/Codec/MIME/String/Flatten.hs   2009-03-05 00:17:59.000000000 +0000
@@ -3,11 +3,12 @@
     (flatten, Attachments, Attachment)
     where

-import qualified Codec.Binary.Base64.String as Base64 (encode)
+import qualified Codec.Binary.Base64 as Base64 (encode)
 import qualified Codec.MIME.String.QuotedPrintable as QP (encode)
 import Codec.MIME.String.Headers
 import Codec.MIME.String.Internal.Utils
 import Codec.MIME.String.Types
+import Data.Char

 {-
 XXX For message IDs:
@@ -63,7 +64,8 @@
                                fn' -> fn')
                        ++ ""\""\n""
                 ++ ""\n""
-                ++ Base64.encode a
+                ++ b64_encode a
+          b64_encode = Base64.encode . map (fromIntegral . ord)
           msg = if single_part
                 then case maybeHtmlBody of
                      Nothing ->
diff -u --recursive mime-string-0.4/Codec/MIME/String/Headers.hs mime-string-0.4_modified/Codec/MIME/String/Headers.hs
--- mime-string-0.4/Codec/MIME/String/Headers.hs    2008-12-05 18:42:47.000000000 +0000
+++ mime-string-0.4_modified/Codec/MIME/String/Headers.hs   2009-03-05 00:15:22.000000000 +0000
@@ -30,7 +30,7 @@
        (<$>), (<$), (<*>), (<*), (<|>), (<|), (<!>),
        pEOI, pPred, pChar, pMany, pAtLeast, pMaybe, pOptDef, pString,
       )
-import qualified Codec.Binary.Base64.String as Base64 (decode)
+import qualified Codec.Binary.Base64 as Base64 (decode)
 import qualified Codec.Binary.EncodingQ.String as EncodingQ (decode)
 import Codec.MIME.String.Internal.Utils

@@ -38,6 +38,7 @@
 import qualified Data.ByteString.Lazy.Char8 as BS
 import Data.Char
 import Data.List
+import Data.Maybe

 -----------------------
 -- Utils
@@ -123,7 +124,9 @@
 -- we'd want to fall back to showing it as a string anyway.
 p_encoding :: Parser Char (String -> String)
 p_encoding = EncodingQ.decode <$  (pChar 'Q' <|> pChar 'q')
-         <|> Base64.decode <$  (pChar 'B' <|> pChar 'b')
+         <|> b64_decode <$  (pChar 'B' <|> pChar 'b')
+         where
+            b64_decode = map (chr . fromIntegral) . fromJust . Base64.decode

 p_encoded_text :: Parser Char String
 p_encoded_text = pMany (pPred (\c -> isAsciiPrint c && c /= '?' && c /= ' '))
diff -u --recursive mime-string-0.4/Codec/MIME/String/Parse.hs mime-string-0.4_modified/Codec/MIME/String/Parse.hs
--- mime-string-0.4/Codec/MIME/String/Parse.hs  2008-12-05 18:42:47.000000000 +0000
+++ mime-string-0.4_modified/Codec/MIME/String/Parse.hs 2009-03-05 00:19:20.000000000 +0000
@@ -1,7 +1,7 @@

 module Codec.MIME.String.Parse where

-import qualified Codec.Binary.Base64.String as Base64 (decode)
+import qualified Codec.Binary.Base64 as Base64 (decode)
 import Codec.MIME.String.ContentDisposition
       (
        ContentDisposition(ContentDisposition), get_content_disposition,
@@ -41,7 +41,8 @@
 import Control.Monad.State (evalState, get, put)
 import qualified Data.ByteString.Lazy.Char8 as BS
 import Data.ByteString.Lazy.Char8 (ByteString)
-import Data.Maybe (fromMaybe)
+import Data.Maybe (fromMaybe, fromJust)
+import Data.Char (chr)

 mkMessage :: MessageInfo -> ParseM MessageContent -> ParseM Message
 mkMessage mi f_mc
@@ -173,9 +174,10 @@
                               get_content_transfer_encoding
        cte@(ContentTransferEncoding content_transfer_encoding)
            = fromMaybe (ContentTransferEncoding ""7bit"") m_ce
+       b64_decode = map (chr . fromIntegral) . fromJust . Base64.decode
        m_decoded_body
         = if content_transfer_encoding == ""base64"" then
-              Just (Base64.decode body)
+              Just (b64_decode body)
           else if content_transfer_encoding == ""quoted-printable"" then
               Just (QuotedPrintable.decode $ my_lines body)
           else if content_transfer_encoding `elem`
diff -u --recursive mime-string-0.4/mime-string.cabal mime-string-0.4_modified/mime-string.cabal
--- mime-string-0.4/mime-string.cabal   2008-12-05 18:42:47.000000000 +0000
+++ mime-string-0.4_modified/mime-string.cabal  2009-03-04 23:51:07.000000000 +0000
@@ -12,7 +12,7 @@
     Implementation of the MIME RFCs 2045-2049.
     Rather rough around the edges at the moment.
 Category:           Codec
-Build-Depends:      base, mtl, network, iconv, base64-string, old-time, bytestring
+Build-Depends:      base, mtl, network, iconv, dataenc, old-time, bytestring
 Extensions:         PatternGuards
 Extra-source-files: ""BSD3"", ""GPL-2""
 Exposed-modules:
}}}
"	igloo
