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 2db20a7 commit d31ecf7
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 @@ -3205,7 +3205,7 @@ def normalize_searching_criteria(criteria)

def coerce_search_arg_to_seqset?(obj)
case obj
when Set, -1 then true
when Set, -1, :* then true
when Range then true
when Array then true
else false
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 d31ecf7

Please sign in to comment.