From 21e4ade56b4261c549fd03f96f4430946d028bea Mon Sep 17 00:00:00 2001 From: shugo Date: Sun, 27 Aug 2017 06:32:00 +0000 Subject: [PATCH] lib/net/imap.rb: Accept continuation requests without response text The IMAP server of DOCOMO returns such continuation requests. [ruby-list:50558] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/imap.rb | 11 ++++++++--- test/net/imap/test_imap.rb | 2 +- test/net/imap/test_imap_response_parser.rb | 10 +++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/net/imap.rb b/lib/net/imap.rb index dc185183cd..bb6754c732 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -964,7 +964,7 @@ module Net @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 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 diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb index e4466fe8dd..0f64e882cc 100644 --- a/test/net/imap/test_imap.rb +++ b/test/net/imap/test_imap.rb @@ -432,7 +432,7 @@ class IMAPTest < Test::Unit::TestCase c.signal end end - assert_raise(Net::IMAP::Error) do + assert_raise(EOFError) do imap.idle do |res| m.synchronize do in_idle = true diff --git a/test/net/imap/test_imap_response_parser.rb b/test/net/imap/test_imap_response_parser.rb index b8c6db86cd..7aac2786fe 100644 --- a/test/net/imap/test_imap_response_parser.rb +++ b/test/net/imap/test_imap_response_parser.rb @@ -60,7 +60,7 @@ EOF def test_flag_xlist_inbox parser = Net::IMAP::ResponseParser.new - response = parser.parse(<