Skip to content

Commit 2db20a7

Browse files
committed
✨ Coerce Set search args into sequence-set
1 parent d35835c commit 2db20a7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/net/imap.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,7 @@ def uid_expunge(uid_set)
19451945
# * When +criteria+ is an array, each member is a +SEARCH+ command argument:
19461946
# * Any SequenceSet sends SequenceSet#valid_string.
19471947
# These types are converted to SequenceSet for validation and encoding:
1948+
# * +Set+
19481949
# * +Range+
19491950
# * <tt>-1</tt> translates to <tt>*</tt>
19501951
# * nested +Array+
@@ -3204,7 +3205,7 @@ def normalize_searching_criteria(criteria)
32043205

32053206
def coerce_search_arg_to_seqset?(obj)
32063207
case obj
3207-
when -1 then true
3208+
when Set, -1 then true
32083209
when Range then true
32093210
when Array then true
32103211
else false

test/net/imap/test_imap.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,9 @@ def test_unselect
12241224
imap.search(["SUBJECT", "1,*"])
12251225
assert_equal 'SUBJECT "1,*"', server.commands.pop.args
12261226

1227+
imap.search(["subject", "hello", Set[1, 2, 3, 4, 5, 8, *(10..100)]])
1228+
assert_equal "subject hello 1:5,8,10:100", server.commands.pop.args
1229+
12271230
server.on "UID SEARCH", &search_resp
12281231
assert_equal search_result, imap.uid_search(["subject", "hello",
12291232
[1..22, 30..-1]])

0 commit comments

Comments
 (0)