Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Network/HaskellNet/IMAP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
do (c, num) <- sendCommand' conn $ "AUTHENTICATE " ++ show at
let challenge =
if BS.take 2 c == BS.pack "+ "
then A.b64Decode $ BS.unpack $ head $

Check warning on line 263 in src/Network/HaskellNet/IMAP.hs

View workflow job for this annotation

GitHub Actions / stack / ghc 9.8.4

In the use of ‘head’

Check warning on line 263 in src/Network/HaskellNet/IMAP.hs

View workflow job for this annotation

GitHub Actions / stack / ghc 9.10.2

In the use of ‘head’

Check warning on line 263 in src/Network/HaskellNet/IMAP.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.8.4

In the use of ‘head’

Check warning on line 263 in src/Network/HaskellNet/IMAP.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.10.2

In the use of ‘head’

Check warning on line 263 in src/Network/HaskellNet/IMAP.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.8.4

In the use of ‘head’

Check warning on line 263 in src/Network/HaskellNet/IMAP.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.10.2

In the use of ‘head’
dropWhile (isSpace . BS.last) $ BS.inits $ BS.drop 2 c
else ""
bsPutCrLf (stream conn) $ BS.pack $
Expand Down Expand Up @@ -332,7 +332,7 @@
, fstr, tstr, " {" ++ show len ++ "}"])
when (BS.null buf || (BS.head buf /= '+')) $
fail "illegal server response"
mapM_ (bsPutCrLf $ stream conn) mailLines
bsPut (stream conn) mailData
bsPutCrLf (stream conn) BS.empty
buf2 <- getResponse $ stream conn
let (resp, mboxUp, ()) = eval pNone (show6 num) buf2
Expand All @@ -341,8 +341,7 @@
NO _ msg -> fail ("NO: "++msg)
BAD _ msg -> fail ("BAD: "++msg)
PREAUTH _ msg -> fail ("PREAUTH: "++msg)
where mailLines = BS.lines mailData
len = sum $ map ((2+) . BS.length) mailLines
where len = BS.length mailData
tstr = maybe "" ((" "++) . datetimeToStringIMAP) time
fstr = maybe "" ((" ("++) . (++")") . unwords . map show) flags'

Expand Down
20 changes: 16 additions & 4 deletions test/IMAPParsersTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import Network.HaskellNet.IMAP.Parsers
import Network.HaskellNet.IMAP.Types
import System.Exit

import System.Exit

import Test.HUnit

data ReadStep = ReadLine ByteString | ReadBytes ByteString
Expand Down Expand Up @@ -297,6 +295,19 @@ imapCommandTest =
[(MESSAGES, 1)] @=? statusResult
actual <- written
commandBytes "000000 STATUS \"foo bar\" (MESSAGES)" @=? actual
, "append preserves raw crlf message bytes" ~: TestCase $ do
let mailData = BS.pack "Subject: x\r\n\r\nBody\r\n"
expectedCommand = "000000 APPEND INBOX {" ++ show (BS.length mailData) ++ "}"
(conn, written) <- scriptedConnection
[ line "+ Ready for literal"
, okLine "APPEND completed"
]
IMAP.append conn "INBOX" mailData
actual <- written
B.concat [ commandBytes expectedCommand
, mailData
, BS.pack "\r\n"
] @=? actual
, "append quotes mailbox" ~: TestCase $ do
let mailData = BS.pack "Body"
(conn, written) <- scriptedConnection
Expand All @@ -305,8 +316,9 @@ imapCommandTest =
]
IMAP.append conn "foo bar" mailData
actual <- written
B.concat [ commandBytes "000000 APPEND \"foo bar\" {6}"
, BS.pack "Body\r\n\r\n"
B.concat [ commandBytes ("000000 APPEND \"foo bar\" {" ++ show (BS.length mailData) ++ "}")
, mailData
, BS.pack "\r\n"
] @=? actual
, assertCommand "copy quotes mailbox"
(commandBytes "000000 UID COPY 42 \"foo bar\"")
Expand Down
Loading