ruby-changes:47550
From: shugo <ko1@a...>
Date: Sun, 27 Aug 2017 15:32:06 +0900 (JST)
Subject: [ruby-changes:47550] shugo:r59666 (trunk): lib/net/imap.rb: Accept continuation requests without response text
shugo 2017-08-27 15:32:00 +0900 (Sun, 27 Aug 2017) New Revision: 59666 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59666 Log: lib/net/imap.rb: Accept continuation requests without response text The IMAP server of DOCOMO returns such continuation requests. [ruby-list:50558] Modified files: trunk/lib/net/imap.rb trunk/test/net/imap/test_imap.rb trunk/test/net/imap/test_imap_response_parser.rb Index: test/net/imap/test_imap_response_parser.rb =================================================================== --- test/net/imap/test_imap_response_parser.rb (revision 59665) +++ test/net/imap/test_imap_response_parser.rb (revision 59666) @@ -60,7 +60,7 @@ EOF https://github.com/ruby/ruby/blob/trunk/test/net/imap/test_imap_response_parser.rb#L60 def test_flag_xlist_inbox parser = Net::IMAP::ResponseParser.new - response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint) + response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint) * XLIST (\\Inbox) "." "INBOX" EOF assert_equal [:Inbox], response.data.attr @@ -311,4 +311,12 @@ EOF https://github.com/ruby/ruby/blob/trunk/test/net/imap/test_imap_response_parser.rb#L311 response = parser.parse("* 1 FETCH (FLAGS (\Seen) MODSEQ (12345) UID 5)\r\n") assert_equal(12345, response.data.attr["MODSEQ"]) end + + def test_continuation_request_without_response_text + parser = Net::IMAP::ResponseParser.new + response = parser.parse("+\r\n") + assert_instance_of(Net::IMAP::ContinuationRequest, response) + assert_equal(nil, response.data.code) + assert_equal("", response.data.text) + end end Index: test/net/imap/test_imap.rb =================================================================== --- test/net/imap/test_imap.rb (revision 59665) +++ test/net/imap/test_imap.rb (revision 59666) @@ -432,7 +432,7 @@ class IMAPTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/imap/test_imap.rb#L432 c.signal end end - assert_raise(Net::IMAP::Error) do + assert_raise(EOFError) do imap.idle do |res| m.synchronize do in_idle = true Index: lib/net/imap.rb =================================================================== --- lib/net/imap.rb (revision 59665) +++ lib/net/imap.rb (revision 59666) @@ -964,7 +964,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/imap.rb#L964 @idle_done_cond.wait(timeout) @idle_done_cond = nil if @receiver_thread_terminating - raise Net::IMAP::Error, "connection closed" + raise @exception || Net::IMAP::Error.new("connection closed") end ensure unless @receiver_thread_terminating @@ -2268,8 +2268,13 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/imap.rb#L2268 def continue_req match(T_PLUS) - match(T_SPACE) - return ContinuationRequest.new(resp_text, @str) + token = lookahead + if token.symbol == T_SPACE + shift_token + return ContinuationRequest.new(resp_text, @str) + else + return ContinuationRequest.new(ResponseText.new(nil, ""), @str) + end end def response_untagged -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/