snoyberg/mime-mail — pull request #34 by romanb (2014-12-07 13:27:42+00:00)
Title: Add a soft line break when hitting a QPEscape at the end of an encoded line.

I was running into a situation where unwanted whitespace appeared in the received e-mails in the middle of names containing multi-byte characters that need escaping. This seems to be due to not using a soft line break when hitting a `QPEscape` at the end of an encoded line. An example in a `cabal repl` session:

:set -XOverloadedStrings
import Network.Mail.Mime
import qualified Blaze.ByteString.Builder as B
import Data.Text.Lazy.Encoding (encodeUtf8)

B.toLazyByteString $ quotedPrintable True $ encodeUtf8 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaøaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n=C3=B8aaa"

With the patch this looks as follows and renders properly in the e-mail (i.e. without whitespace):

B.toLazyByteString $ quotedPrintable True $ encodeUtf8 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaøaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=\r\n=C3=B8aaa"

I'm not entirely sure whether I fixed it in the right place or whether this might cause other issues. The existing tests still seem to be happy.