Bug #9895

net/imap stops responding when trying to create a message to an unexisting folder

Added by Lluís Gili 11 months ago. Updated 11 months ago.

[ruby-core:62906]
Status:Feedback
Priority:Normal
Assignee:Shugo Maeda
ruby -v:ruby 2.0.0p353 (2013-11-22) [i386-linux-gnu] Backport:2.0.0: UNKNOWN, 2.1: UNKNOWN

Description

trying to create a message to unexisting folder makes net/imap to eternize, instead of raising an exception:

2.0.0p353> require 'net/imap'
0.0600 (0.1808) => true
2.0.0p353> imap   = Net::IMAP.new('mail.example.com', 143, false)
0.0100 (0.3245) => #<Net::IMAP:0x965e7b8 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x965e790>, @host"mail.example.com", @port143, @tag_prefix"RUBY", @tagno0, @parser#<Net::IMAP::ResponseParser:0x965e6f0 @str="* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.\r\n", @pos=123, @lex_state=:EXPR_BEG, @token=nil, @flag_symbols={}>, @sock#<TCPSocket:fd 7, @usessl=false, @responses={}, @tagged_responses={}, @response_handlers=[], @tagged_response_arrival=#<MonitorMixin::ConditionVariable:0x965e664 @monitor=#<Net::IMAP:0x965e7b8 ...>, @cond#<ConditionVariable:0x965e650 @waiters={}, @waiters_mutex=#<Mutex:0x965e628>, @continuation_request_arrival#<MonitorMixin::ConditionVariable:0x965e614 @monitor=#<Net::IMAP:0x965e7b8 ...>, @cond#<ConditionVariable:0x965e600 @waiters={}, @waiters_mutex=#<Mutex:0x965e5d8>, @idle_done_condnil, @logout_command_tagnil, @debug_output_boltrue, @exceptionnil, @greeting#<struct Net::IMAP::UntaggedResponse name="OK", data=#<struct Net::IMAP::ResponseText code=#<struct Net::IMAP::ResponseCode name="CAPABILITY", data="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN", text=" Dovecot ready.", raw_data="* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.\r\n", @client_thread=#<Thread:0x8eadeec run>, @receiver_thread#<Thread:0x965de80 sleep, @receiver_thread_terminating=false>
2.0.0p353> imap.login 'user', 'pass'
0.0000 (2.2579) => #<struct Net::IMAP::TaggedResponse tag="RUBY0001", name="OK", data=#<struct Net::IMAP::ResponseText code=#<struct Net::IMAP::ResponseCode name="CAPABILITY", data="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE QUOTA">, text=" Logged in">, raw_data="RUBY0001 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE QUOTA] Logged in\r\n">
2.0.0p353> imap.list('','INBOX/Drafts')
0.0000 (0.2124) => nil
2.0.0p353> imap.append("INBOX/Drafts", <<EOF.gsub(/\n/, "\r\n"), [:Draft], Time.now)
2.0.0p353> Subject: hello
2.0.0p353> From: shugo@ruby-lang.org
2.0.0p353> To: shugo@ruby-lang.org
2.0.0p353>
2.0.0p353> hello world
2.0.0p353> EOF

History

#1 Updated by Shugo Maeda 11 months ago

  • Status changed from Open to Assigned
  • Assignee set to Shugo Maeda

#2 Updated by Shugo Maeda 11 months ago

  • Status changed from Assigned to Feedback

Lluís Gili wrote:

trying to create a message to unexisting folder makes net/imap to eternize, instead of raising an exception:

The following exception is raised on my box:

$ ruby -v imaptest.rb
ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux]
nil
/home/shugo/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/net/imap.rb:1156:in `get_tagged_response':  Folder doesn't exist. (Failure) (Net::IMAP::NoResponseError)
    from /home/shugo/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/net/imap.rb:1210:in `block in send_command'
    from /home/shugo/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
    from /home/shugo/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/net/imap.rb:1192:in `send_command'
    from /home/shugo/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/net/imap.rb:700:in `append'
    from imaptest.rb:6:in `<main>'

Please set Net::IMAP.debug to true, and show me the output.
(Net::IMAP doesn't sanitize your password in debug logs, so please do it yourself.)

Also available in: Atom PDF