Skip to content

Commit

Permalink
Merge pull request #1612 from nevans/backport/stop-mutating-imap-resp…
Browse files Browse the repository at this point in the history
…onse

Backport: Fix IMAP search issues
  • Loading branch information
eval authored Jun 5, 2024
2 parents d629660 + 59358b3 commit 20bc36c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/mail/network/retriever_methods/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def find(options=nil, &block)

start do |imap|
options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])

uids = imap.uid_search(options[:keys], options[:search_charset])
.to_a # older net-imap may return nil, newer may return ESearchResult struct
.sort # RFC3501 does _not_ require UIDs to be returned in order
uids.reverse! if options[:what].to_sym == :last
uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||
Expand Down

0 comments on commit 20bc36c

Please sign in to comment.