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

search fails #348

Closed
ghost opened this issue Jun 5, 2016 · 4 comments
Closed

search fails #348

ghost opened this issue Jun 5, 2016 · 4 comments
Labels
compatibility Compatibility with existing software server-bug The bug appears to be in the server

Comments

@ghost
Copy link

ghost commented Jun 5, 2016

S: * OK [PERMANENTFLAGS ()] No permanent flags permitted
S: A00000004 OK [READ-ONLY] EXAMINE complete
C: A00000005 UID SEARCH CHARSET US-ASCII OR SUBJECT sdf BODY sdf
S: A00000005 BAD UID SEARCH invalid argument

when i searching for something, the server replied a "BAD" response.

@jstedfast
Copy link
Owner

Your server is broken. That is perfectly valid syntax.

From rfc3501:

search          = "SEARCH" [SP "CHARSET" SP astring] 1*(SP search-key)
                    ; CHARSET argument to MUST be registered with IANA

search-key      = "ALL" / "ANSWERED" / "BCC" SP astring /
                  "BEFORE" SP date / "BODY" SP astring /
                  "CC" SP astring / "DELETED" / "FLAGGED" /
                  "FROM" SP astring / "KEYWORD" SP flag-keyword /
                  "NEW" / "OLD" / "ON" SP date / "RECENT" / "SEEN" /
                  "SINCE" SP date / "SUBJECT" SP astring /
                  "TEXT" SP astring / "TO" SP astring /
                  "UNANSWERED" / "UNDELETED" / "UNFLAGGED" /
                  "UNKEYWORD" SP flag-keyword / "UNSEEN" /
                    ; Above this line were in [IMAP2]
                  "DRAFT" / "HEADER" SP header-fld-name SP astring /
                  "LARGER" SP number / "NOT" SP search-key /
                  "OR" SP search-key SP search-key /
                  "SENTBEFORE" SP date / "SENTON" SP date /
                  "SENTSINCE" SP date / "SMALLER" SP number /
                  "UID" SP sequence-set / "UNDRAFT" / sequence-set /
                  "(" search-key *(SP search-key) ")"

In section 6.4.4, it also states:

      The OPTIONAL [CHARSET] specification consists of the word
      "CHARSET" followed by a registered [CHARSET].  It indicates the
      [CHARSET] of the strings that appear in the search criteria.
      [MIME-IMB] content transfer encodings, and [MIME-HDRS] strings in
      [RFC-2822]/[MIME-IMB] headers, MUST be decoded before comparing
      text in a [CHARSET] other than US-ASCII.  US-ASCII MUST be
      supported; other [CHARSET]s MAY be supported.

      If the server does not support the specified [CHARSET], it MUST
      return a tagged NO response (not a BAD).  This response SHOULD
      contain the BADCHARSET response code, which MAY list the
      [CHARSET]s supported by the server.

Based on these, we know that:

UID SEARCH CHARSET US-ASCII OR SUBJECT sdf BODY sdf

is perfectly valid syntax.

If you try this exact same search query on, say, GMail, it will work. If you try it with a Dovecot IMAP server, it will work. If you try it on pretty much every IMAP server other than yours, it will work.

What IMAP server are you using? What if you don't use an OR search?

jstedfast added a commit that referenced this issue Jun 5, 2016
This might work around some broken IMAP servers that don't properly
implement the specification such as the one in issue #348
@jstedfast
Copy link
Owner

If this patch doesn't work around your broken IMAP server, there's nothing else I can do...

@jstedfast jstedfast added the compatibility Compatibility with existing software label Jun 5, 2016
@ghost
Copy link
Author

ghost commented Jun 6, 2016

thanks for your answer!
Jeffrey Stedfast [email protected]于2016年6月5日星期日 19:12写道:

If this patch doesn't work around your broken IMAP server, there's nothing
else I can do...


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#348 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AQWAobxQFM0IfMoH1mnk7Qzz-p8riJW4ks5qIq8YgaJpZM4IuSSG
.

@jstedfast
Copy link
Owner

I have published a new version of MailKit that fixes this issue to nuget

@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

1 participant