Skip to content

Commit 20bc36c

Browse files
authored
Merge pull request #1612 from nevans/backport/stop-mutating-imap-response
Backport: Fix IMAP search issues
2 parents d629660 + 59358b3 commit 20bc36c

File tree

1 file changed

+3
-0
lines changed
  • lib/mail/network/retriever_methods

1 file changed

+3
-0
lines changed

lib/mail/network/retriever_methods/imap.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def find(options=nil, &block)
7575

7676
start do |imap|
7777
options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])
78+
7879
uids = imap.uid_search(options[:keys], options[:search_charset])
80+
.to_a # older net-imap may return nil, newer may return ESearchResult struct
81+
.sort # RFC3501 does _not_ require UIDs to be returned in order
7982
uids.reverse! if options[:what].to_sym == :last
8083
uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
8184
uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||

0 commit comments

Comments
 (0)