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 untagged Fetch response. Unexpected token: '('" (Domino IMAP4 Server) #943

Closed
zmarkusdev opened this issue Oct 30, 2019 · 5 comments
Labels
compatibility Compatibility with existing software server-bug The bug appears to be in the server

Comments

@zmarkusdev
Copy link

Describe the bug
Hi!

I am trying to fetch from a Domino IMAP4 Server with the following fetch command:
IList<IMessageSummary> results = folder.Fetch(0,-1, MessageSummaryItems.Envelope | MessageSummaryItems.BodyStructure | MessageSummaryItems.UniqueId);

I am getting the following error:

Syntax error in untagged FETCH response. Unexpected token: '('

In this special case I tried to fetch the messages in the folder "Trash", in other folders, the fetch command ran successfully.

To Reproduce
Steps to reproduce the behavior:

  1. Connect with Lotus Domino Server via IMAP
  2. Open folder "Trash"
  3. Try to fetch messages with the options "MessageSummaryItems.Envelope | MessageSummaryItems.BodyStructure | MessageSummaryItems.UniqueId"
  4. Exception is thrown

Expected behavior
I expected to get the list of messages in the trash folder returned.

Desktop (please complete the following information):

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

Additional context
Here is my imap.log for further details:

Connected to imap://qqq1.dpi.local:143/?starttls=when-available
S: * OK Domino IMAP4 Server Release 10.0.1FP3 ready Wed, 30 Oct 2019 09:28:06 +0100
C: A00000000 CAPABILITY
S: * CAPABILITY IMAP4rev1 AUTH=PLAIN LITERAL+ NAMESPACE QUOTA UIDPLUS
S: A00000000 OK CAPABILITY completed
C: A00000001 AUTHENTICATE PLAIN
S: +
C: *************************************
S: A00000001 OK AUTHENTICATE completed
C: A00000002 CAPABILITY
S: * CAPABILITY IMAP4rev1 AUTH=PLAIN LITERAL+ NAMESPACE QUOTA UIDPLUS
S: A00000002 OK CAPABILITY completed
C: A00000003 NAMESPACE
S: * NAMESPACE (("" "\")) (("Andere Benutzer\" "\")) (("&ANY-ffentliche Ordner\" "\"))
S: A00000003 OK NAMESPACE completed
C: A00000004 LIST "" "INBOX"
S: * LIST (\Noinferiors \HasNoChildren) "\" Inbox
S: A00000004 OK LIST completed
C: A00000005 LIST "" Trash
S: * LIST (\Noinferiors \HasNoChildren) "\" Trash
S: A00000005 OK LIST completed
C: A00000006 EXAMINE Trash
S: * 3166 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 8] UIDs valid
S: * OK [UIDNEXT 200010] Predicted next UID
S: * FLAGS (\Flagged \Seen \Answered \Deleted \Draft)
S: * OK [PERMANENTFLAGS ()] No permanent flags permitted
S: A00000006 OK [READ-ONLY] EXAMINE completed
C: A00000007 FETCH 1:* (UID ENVELOPE BODYSTRUCTURE)
S: * 2 FETCH (UID 14935 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 4 FETCH (UID 14937 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 3 FETCH (UID 14936 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 1 FETCH (UID 14934 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 6 FETCH (UID 14939 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 5 FETCH (UID 14938 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 8 FETCH (UID 14941 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 7 FETCH (UID 14940 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 10 FETCH (UID 14943 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 9 FETCH (UID 14942 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 14 FETCH (UID 14947 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 13 FETCH (UID 14946 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 15 FETCH (UID 14948 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 11 FETCH (UID 14944 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 12 FETCH (UID 14945 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 17 FETCH (UID 14950 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 16 FETCH (UID 14949 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 19 FETCH (UID 14952 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 18 FETCH (UID 14951 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 20 FETCH (UID 14953 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 21 FETCH (UID 14954 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 24 FETCH (UID 14957 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 23 FETCH (UID 14956 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 22 FETCH (UID 14955 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 25 FETCH (UID 14958 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 26 FETCH (UID 14959 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 28 FETCH (UID 14961 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 27 FETCH (UID 14960 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 29 FETCH (UID 14962 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))
S: * 30 FETCH (UID 14963 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEX

@jstedfast
Copy link
Owner

jstedfast commented Oct 30, 2019

The problem is that the IMAP server is adding an extra set of ()'s around the ENVELOPE segment of the response:

S: * 2 FETCH (UID 14935 (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))

It should, instead, look like this:

S: * 2 FETCH (UID 14935 ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) BODYSTRUCTURE ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 0 0 NIL))

jstedfast added a commit that referenced this issue Oct 30, 2019
@jstedfast
Copy link
Owner

Do you have custom work-arounds for Domino bugs?

I ask because in my attempt to unit test this fix, I discovered more bugs in Domino Server in that it doesn't escape the \ character when inside of a quoted-string token which is breaking MailKit as well in commands like NAMESPACE and LIST.

@jstedfast
Copy link
Owner

You can test the above fix by installing the latest MailKit nuget from https://www.myget.org/feed/mimekit/package/nuget/MailKit

@jstedfast jstedfast added the compatibility Compatibility with existing software label Oct 30, 2019
@jstedfast
Copy link
Owner

jstedfast commented Oct 30, 2019

Never mind about the \ issue, it seems GitHub's editor is rendering a double-\ as a single \.

@zmarkusdev
Copy link
Author

Thanks for the fix, works as expected!

@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