Skip to content

Commit e1e59d0

Browse files
hoffiStefan Hoffmann
authored andcommitted
Fixed wrong parser type
1 parent 3b57605 commit e1e59d0

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

lib/net/imap/response_parser.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,13 +1342,19 @@ def number
13421342
end
13431343

13441344
def set
1345-
token = match(T_ATOM)
1346-
token.value.split(',').flat_map do |element|
1347-
if element.include?(':')
1348-
Range.new(*element.split(':').map(&:to_i)).to_a
1349-
else
1350-
element.to_i
1345+
case lookahead.symbol
1346+
when T_NUMBER then [match(T_NUMBER).value.to_i]
1347+
when T_ATOM
1348+
match(T_ATOM).value.split(',').flat_map do |element|
1349+
if element.include?(':')
1350+
Range.new(*element.split(':').map(&:to_i)).to_a
1351+
else
1352+
element.to_i
1353+
end
13511354
end
1355+
else
1356+
shift_token
1357+
nil
13521358
end
13531359
end
13541360

test/net/imap/test_imap.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,12 +825,14 @@ def test_uidplus_responses
825825
requests.push(sock.gets)
826826
sock.print("RUBY0002 OK [COPYUID 38505 3955,3960:3962 3963:3966] " \
827827
"COPY completed\r\n")
828+
requests.push(sock.gets)
829+
sock.print("RUBY0003 OK [COPYUID 38505 3955 3967] COPY completed\r\n")
828830
sock.gets
829831
sock.print("* NO [UIDNOTSTICKY] Non-persistent UIDs\r\n")
830-
sock.print("RUBY0003 OK SELECT completed\r\n")
832+
sock.print("RUBY0004 OK SELECT completed\r\n")
831833
sock.gets
832834
sock.print("* BYE terminating connection\r\n")
833-
sock.print("RUBY0004 OK LOGOUT completed\r\n")
835+
sock.print("RUBY0005 OK LOGOUT completed\r\n")
834836
ensure
835837
sock.close
836838
server.close
@@ -853,6 +855,9 @@ def test_uidplus_responses
853855
resp,
854856
[38505, [3955, 3960, 3961, 3962], [3963, 3964, 3965, 3966]]
855857
)
858+
resp = imap.uid_copy(3955, 'trash')
859+
assert_equal(requests.pop, "RUBY0003 UID COPY 3955 trash\r\n")
860+
assert_equal(resp, [38505, [3955], [3967]])
856861
imap.select('trash')
857862
assert_equal(
858863
imap.responses["NO"].last.code,

0 commit comments

Comments
 (0)