You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the end of a FETCH reply, just before the terminating ), Office365 accounts have an added line of the format UID nn FLAGS (\Seen). This results in a parse error: expected space or ).
Example very last few lines of reply which does not fail:
\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n)\r\n000004 OK FETCH completed.\r\n
Example very last few lines of Office365 reply which fails:
\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nUID 12 FLAGS (\Seen))\r\n000004 OK FETCH completed.\r\n
I am motivated to do some work, but I would need to spend some time to get into the parser library first. I might not get time in a while. Is the
parser the same, or based on, or not related to Text.GrammarCombinators.Parser.Packrat from grammar-combinators?
For my application all I need is to ditch this flag and make it work, so perhaps a dirty fix first.
This is fixed on current master. The FETCH response is no longer parsed by the old Parsec pFetchLine (which demanded a space or ) right after the body) — it's now handled by a streaming parser that consumes key/value pairs until the closing ), so the trailing UID nn FLAGS (\Seen) that Office365/Exchange emit after the BODY[] literal is tolerated and IMAP.fetch returns the body intact.
I verified against the exact wire shape from this report and added a regression test for it in #114 (cabal test imap-parsers → 48/48). Closing as fixed.
Activity
jtdaugherty commentedon Jan 15, 2014
Thanks for the report! Do you have time to write a patch?
fegu commentedon Jan 15, 2014
I am motivated to do some work, but I would need to spend some time to get into the parser library first. I might not get time in a while. Is the
parser the same, or based on, or not related to Text.GrammarCombinators.Parser.Packrat from grammar-combinators?
For my application all I need is to ditch this flag and make it work, so perhaps a dirty fix first.
:: Finn Espen Gundersen
On 15 Jan 2014, at 21:55, Jonathan Daugherty notifications@github.com wrote:
dkov01 commentedon Jun 2, 2016
This bug also occurs on MS Exchange Server 2010+ as reported.
farrellm commentedon Sep 5, 2019
I can't make a pull request at the moment, but here's a patch to fix this (though someone should test it does not break non-MS emails):
mpscholten commentedon Jun 13, 2026
This is fixed on current
master. The FETCH response is no longer parsed by the old ParsecpFetchLine(which demanded a space or)right after the body) — it's now handled by a streaming parser that consumes key/value pairs until the closing), so the trailingUID nn FLAGS (\Seen)that Office365/Exchange emit after theBODY[]literal is tolerated andIMAP.fetchreturns the body intact.I verified against the exact wire shape from this report and added a regression test for it in #114 (
cabal test imap-parsers→ 48/48). Closing as fixed.Add regression test for Office365/Exchange trailing FETCH fields (#15)
Merge pull request #114 from mpscholten/regression-test-imap-15-offic…