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

"Syntax error in BODYSTRUCTURE. Unexpected token: ')'" (Domino IMAP4 Server) #944

Closed
zmarkusdev opened this issue Nov 7, 2019 · 1 comment
Labels
compatibility Compatibility with existing software server-bug The bug appears to be in the server

Comments

@zmarkusdev
Copy link

zmarkusdev commented Nov 7, 2019

Describe the bug
Hi again :-)

I detected another incompatibility with Lotus Domino. Maybe you are able to fix this problem I am experiencing.

To Reproduce
From the logs:

C: J00000028 UID FETCH 23064 (UID FLAGS ENVELOPE BODYSTRUCTURE)
S: * 9125 FETCH (UID 23064 ENVELOPE ("6 Nov 2019 09:12:02 +0100" "DELIVERY FAILURE: 550 #5.1.0 Address rejected." ((NIL NIL "postmaster" "pmta.censored.co.at")) ((NIL NIL "postmaster" "pmta.censored.co.at")) ((NIL NIL "postmaster" "pmta.censored.co.at")) ((NIL NIL "support" "censored.rocks")) NIL NIL NIL "OF0E3BFDBA.E44C42DB-ONC12584AA.002D0EF8@censored.com") BODYSTRUCTURE (("text" "plain" ("charset" "UTF-8") NIL NIL "base64" 232 4 NIL NIL NIL)("message" "delivery-status" NIL NIL NIL "7BIT" 421 NIL NIL NIL)("message" "rfc822" NIL NIL NIL "7BIT" 787 (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) () 0 NIL NIL NIL) "report" ("report-type" "delivery-status" "boundary" "==IFJRGLKFGIR60132UHRUHIHD") NIL NIL) FLAGS (\Seen))
S: J00000028 OK FETCH completed

I get the following exception:

MailKit.Net.Imap.ImapProtocolException: Syntax error in BODYSTRUCTURE. Unexpected token: ')'

Expected behavior
Getting no error because of the Lotus Domino syntax error, maybe having another QuirksMode implementation for this problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • .Net Framework 4.6.1
  • Version 2.3.2.16

Do you need more of the log or is this enough for you to reproduce the problem?

I can also provide a pull request on my own if such QuirksMode implementations are desired by you using the last fix you provided (always wanted to get my feet wet in the open source community ;-) ).

Thanks!

@jstedfast jstedfast added the compatibility Compatibility with existing software label Nov 7, 2019
@jstedfast
Copy link
Owner

The problem seems to be the () in the BODYSTRUCTURE value in the response you posted.

According to rfc3501, the syntax for a message/rfc822 body structure is as follows (this is as much for my own info in the future if I ever have to refer back to this issue as it is to inform you if what is going wrong):

body-type-1part = (body-type-basic / body-type-msg / body-type-text)
                  [SP body-ext-1part]
body-type-mpart = 1*body SP media-subtype
                  [SP body-ext-mpart]
body-type-msg   = media-message SP body-fields SP envelope
                  SP body SP body-fld-lines
media-message   = DQUOTE "MESSAGE" DQUOTE SP DQUOTE "RFC822" DQUOTE
                    ; Defined in [MIME-IMT]
body-fields     = body-fld-param SP body-fld-id SP body-fld-desc SP
                  body-fld-enc SP body-fld-octets
body            = "(" (body-type-1part / body-type-mpart) ")"
body-ext-1part  = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang
                  [SP body-fld-loc *(SP body-extension)]]]
                    ; MUST NOT be returned on non-extensible
                    ; "BODY" fetch

So... this:

("message" "rfc822" NIL NIL NIL "7BIT" 787 (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) () 0 NIL NIL NIL)

can be broken down into these tokens:

media-message tokens = "message" "rfc822"
body-fld-param token = NIL
body-fld-id token = NIL
body-fld-desc token = NIL
body-fld-enc token = "7BIT"
body-fld-octets token = 787
envelope tokens = (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)
body token = ()
body-fld-lines = 0

and the remaining 3 NILs are the body-ext-1part extensions:

body-fld-md5 token = NIL
body-fld-dsp token = NIL
body-fld-lang token = NIL

The problem is that a body token expects a list of values and not just () - there's gotta be a body-type-1part or a body-type-mpart within those ()'s, but there isn't.

Anyway... I guess I'll just treat () as a NULL body.

jstedfast added a commit that referenced this issue Nov 7, 2019
@jstedfast jstedfast added the server-bug The bug appears to be in the server label Nov 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with existing software server-bug The bug appears to be in the server
Projects
None yet
Development

No branches or pull requests

2 participants