Skip to content

Commit

Permalink
✨ Coerce :* search args into sequence-set
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed Nov 8, 2024
1 parent b39ab74 commit 24faaac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ def uid_expunge(uid_set)
# These types are converted to SequenceSet for validation and encoding:
# * +Set+
# * +Range+
# * <tt>-1</tt> translates to <tt>*</tt>
# * <tt>-1</tt> and +:*+ -- both translate to <tt>*</tt>
# * nested +Array+
# * Any +String+ is sent verbatim when it is a valid \IMAP atom,
# and encoded as an \IMAP quoted or literal string otherwise.
Expand Down Expand Up @@ -3196,7 +3196,7 @@ def normalize_searching_criteria(criteria)
return RawData.new(criteria) if criteria.is_a?(String)
criteria.map {|arg|
case arg
when Set, -1 then SequenceSet[arg]
when Set, -1, :* then SequenceSet[arg]
when Range then SequenceSet[arg]
when Array then SequenceSet[arg]
else
Expand Down
3 changes: 3 additions & 0 deletions test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,9 @@ def test_unselect
imap.search(["subject", "hello", Set[1, 2, 3, 4, 5, 8, *(10..100)]])
assert_equal "subject hello 1:5,8,10:100", server.commands.pop.args

imap.search([:*])
assert_equal "*", server.commands.pop.args

server.on "UID SEARCH", &search_resp
assert_equal search_result, imap.uid_search(["subject", "hello",
[1..22, 30..-1]])
Expand Down

0 comments on commit 24faaac

Please sign in to comment.