Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMAP.status doesn't work when mailbox name contains a space #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion src/Network/HaskellNet/IMAP/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pListLine list =
pStatusLine :: Parser RespDerivs (Either a [(MailboxStatus, Integer)])
pStatusLine =
do string "* STATUS "
_ <- anyChar `manyTill` space
mbox <- parseMailbox
stats <- between (char '(') (char ')') (parseStat `sepBy1` space)
crlfP
return $ Right stats
Expand All @@ -273,6 +273,11 @@ pStatusLine =
space
num <- many1 digit >>= return . read
return (cons, num)
parseMailbox = do
q <- optional $ char '"'
case q of
Just _ -> do mbox <- anyChar `manyTill` char '"'; space; return mbox
Nothing -> anyChar `manyTill` space

pSearchLine :: Parser RespDerivs (Either a [UID])
pSearchLine = do string "* SEARCH "
Expand Down
10 changes: 9 additions & 1 deletion test/IMAPParsersTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ statusTest =
"* STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292)\r\n\
\A042 OK STATUS completed\r\n"

statusWithSpaceTest =
( OK Nothing "STATUS completed"
, MboxUpdate Nothing Nothing
, [(MESSAGES, 231), (UIDNEXT, 44292)])
~=? eval' pStatus "A042"
"* STATUS \"[Gmail]/Alle Nachrichten\" (MESSAGES 231 UIDNEXT 44292)\r\n\
\A042 OK STATUS completed\r\n"

expungeTest =
( OK Nothing "EXPUNGE completed"
, MboxUpdate Nothing Nothing
Expand Down Expand Up @@ -167,7 +175,7 @@ testData = [ "base" ~: baseTest
, "noop" ~: noopTest
, "select" ~: selectTest
, "list" ~: listTest
, "status" ~: statusTest
, "status" ~: TestList [ statusTest, statusWithSpaceTest ]
, "expunge" ~: expungeTest
, "search" ~: searchTest
, "fetch" ~: fetchTest
Expand Down
Loading