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

ImapFolder.Search(): InvalidCastException #191

Closed
cap5ule opened this issue May 15, 2015 · 2 comments
Closed

ImapFolder.Search(): InvalidCastException #191

cap5ule opened this issue May 15, 2015 · 2 comments
Labels
bug Something isn't working

Comments

@cap5ule
Copy link

cap5ule commented May 15, 2015

System.InvalidCastException: Unable to cast object of type 'System.Int32[]' to type 
   'System.Collections.Generic.IList1[MailKit.UniqueId]'. at MailKit.Net.Imap.ImapFolder.Search(SearchQuery query, CancellationToken cancellationToken)

Exception occurs when attempting to search AOL IMAP Server (imaps://imap.aol.com:99) folders.

jstedfast added a commit that referenced this issue May 16, 2015
@jstedfast
Copy link
Owner

Thanks! Fixed in git master. I don't have time to make a release for the next week or so, but I'll try to make one as soon as I can after that. Hopefully I'll find some time on the 23rd or 24th.

@jstedfast
Copy link
Owner

Ugh, so it looks like AOL's IMAP implementation is broken.

   The ESEARCH response starts with an optional search correlator.  If
   it is missing, then the response was not caused by a particular IMAP
   command, whereas if it is present, it contains the tag of the command
   that caused the response to be returned.

   The search correlator is followed by an optional UID indicator.  If
   this indicator is present, all data in the ESEARCH response refers to
   UIDs, otherwise all returned data refers to message numbers.

It's missing the UID indicator and so what my code was doing was converting the IList into int[] in the ESearch handler. The exception is because the Search() method was casting the search results to an IList since it expected that type since it did a UID SEARCH command.

So... AOL's response is broken because either:

  1. the ESEARCH response should have had the UID indicator (bad)

or

  1. the ESEARCH response returned indexes to a UID SEARCH command (really bad)

If you test out my patch, you'll have to let me know if the values returned match up with UIDs or not.

@jstedfast jstedfast added the bug Something isn't working label May 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants