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

✨ Add basic ESearch support #333

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

nevans
Copy link
Collaborator

@nevans nevans commented Sep 26, 2024

No description provided.

@nevans
Copy link
Collaborator Author

nevans commented Oct 8, 2024

FWIW: I discovered in testing that Yahoo does not return ESEARCH results when RETURN (PARTIAL 1:500) is used, contrary to the PARTIAL RFC that was written by Yahoo engineers!

@nevans nevans added this to the v0.6 milestone Oct 8, 2024
@nevans nevans added the IMAP4rev2 Requirement for IMAP4rev2, RFC9051 label Oct 14, 2024
@nevans nevans force-pushed the basic-esearch-support branch 2 times, most recently from f31c61d to f20f5b4 Compare October 24, 2024 18:58
nevans and others added 5 commits October 25, 2024 16:02
This affects search, uid_search, sort, uid_sort, thread, and uid_thread.

Prior to this, sending a parenthesized list in the search criteria for
any of these commands required the use of strings, which are converted
to RawData, which has security implications with untrusted inputs.

With this change, arrays will only be converted into SequenceSet when
_every_ element in the array is a valid SequenceSet input.  Otherwise,
the array will be left alone, which allows us to send parenthesized
lists without using strings and RawData.

For example, some search criteria this change enables:
* `["not", %w[flagged unread]]` converts to `not (flagged unread)`.
* `["return", ["partial", 1..50]]` converts to `return (partial 1:50)`.
Forward all `#search` and `#uid_search` arguments to `#search_internal`.
This simplifies future changes to search parameters.
nevans and others added 5 commits October 25, 2024 17:08
For new data structs, I'd prefer frozen by default and I don't want to
support the entire Struct API.  Data is perfect, but it's not available
until ruby 3.2.

So this adds a DataLite class that closely matches ruby 3.2's Data
class, and it can be a drop-in replacement for Data.  Net::IMAP::Data
is an alias for Net::IMAP::DataLite, so when we remove our
implementation, the constant will resolve to ruby's ::Data.

Ideally, we wouldn't define this on newer ruby versions at all, but that
breaks the YAML serialization for our test fixtures.

The tests (and some of the implementation) have been copied from the
polyfill-data gem and updated so that they use "Data" as it is resolved
inside the "Net::IMAP" namespace.  Copyright notices have been added to
the appropriate files to satisfy the MIT license terms.
The command needs to know its own tag in order to filter responses based
on it.
Parses +ESEARCH+ into ESearchResult, with support for:
* RFC4466 syntax
* RFC4731 `ESEARCH`
* RFC5267 `CONTEXT=SEARCH`
* RFC6203 `SEARCH=FUZZY`
* RFC9394 `PARTIAL`

For compatibility, `ESearchResult#to_a` returns an array of integers
(sequence numbers or UIDs) whenever any `ALL` or `PARTIAL` result is
available.
* Return empty ESearchResult when no result
* Clear SEARCH responses before new search.  Note that we don't need to
  do this for ESEARCH responses, since they are tagged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IMAP4rev2 Requirement for IMAP4rev2, RFC9051
Development

Successfully merging this pull request may close these issues.

1 participant