[#24105] [Bug #1711] Marshal Failing to Round-Trip Certain Recurisve Data Structures — Run Paint Run Run <redmine@...>

Bug #1711: Marshal Failing to Round-Trip Certain Recurisve Data Structures

9 messages 2009/07/01

[#24116] [Bug #1715] Numeric#arg for NaN is Inconsistent Across Versions — Run Paint Run Run <redmine@...>

Bug #1715: Numeric#arg for NaN is Inconsistent Across Versions

10 messages 2009/07/02

[#24240] [Bug #1755] IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8 — Run Paint Run Run <redmine@...>

Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8

8 messages 2009/07/09

[#24321] [Bug #1773] Gem path doesn't honor user gem? — Lin Jen-Shin <redmine@...>

Bug #1773: Gem path doesn't honor user gem?

12 messages 2009/07/14

[#24390] [Feature #1784] More encoding (Big5 series) support? — Lin Jen-Shin <redmine@...>

Feature #1784: More encoding (Big5 series) support?

12 messages 2009/07/16

[#24467] Re: [ruby-cvs:31226] Ruby:r24008 (ruby_1_8_6): Removed private on to_date and to_datetime. — Urabe Shyouhei <shyouhei@...>

Hello.

10 messages 2009/07/21

[#24472] [Feature #1800] rubygems can replace system executable files — Kazuhiro NISHIYAMA <redmine@...>

Feature #1800: rubygems can replace system executable files

13 messages 2009/07/21

[#24530] [Feature #1811] Default BasicSocket.do_not_reverse_lookup to true — Roger Pack <redmine@...>

Feature #1811: Default BasicSocket.do_not_reverse_lookup to true

9 messages 2009/07/23

[#24624] [Bug #1844] Immediates Should Not Respond to :dup — Run Paint Run Run <redmine@...>

Bug #1844: Immediates Should Not Respond to :dup

15 messages 2009/07/30

[ruby-core:24111] [Bug #1713] IMAP NO response messages are unavailable

From: Eric Hodel <redmine@...>
Date: 2009-07-01 22:25:22 UTC
List: ruby-core #24111
Bug #1713: IMAP NO response messages are unavailable
http://redmine.ruby-lang.org/issues/show/1713

Author: Eric Hodel
Status: Open, Priority: Normal
ruby -v: ruby 1.9.2dev (2009-06-30 trunk 23904) [i386-darwin9.7.0] 

In RFC 3501 the IMAP server may respond with information the user can use to retry their request.

For the COPY command (6.4.7):

      If the destination mailbox does not exist, a server SHOULD return
      an error.  It SHOULD NOT automatically create the mailbox.  Unless
      it is certain that the destination mailbox can not be created, the
      server MUST send the response code "[TRYCREATE]" as the prefix of
      the text of the tagged NO response.  This gives a hint to the
      client that it can attempt a CREATE command and retry the COPY if
      the CREATE is successful.

Also for the SEARCH command (6.4.4):

      If the server does not support the specified [CHARSET], it MUST
      return a tagged NO response (not a BAD).  This response SHOULD
      contain the BADCHARSET response code, which MAY list the
      [CHARSET]s supported by the server.

Net::IMAP doesn't easily give access to this information.  For example:

$ cat imap_copy.rb 
require 'net/imap'

Net::IMAP.debug = true
imap = Net::IMAP.new 'localhost', 143
imap.login 'test', 'test'
imap.select 'INBOX'
uids = imap.search 'ALL'
begin
  imap.copy uids, 'no such mailbox'
  puts 'copy successful'
rescue Net::IMAP::NoResponseError => e
  p e
end
$ ruby imap_copy.rb 
S: * OK Dovecot ready.
[...]
C: RUBY0004 COPY 1 "no such mailbox"
S: RUBY0004 NO [TRYCREATE] Mailbox doesn't exist: no such mailbox
#<Net::IMAP::NoResponseError:  Mailbox doesn't exist: no such mailbox>

Here the server told us we could probably fix this by sending CREATE first, so we could handle this intelligently.  Unfortunately, we can't tell if the mailbox outright doesn't exist or if it simply can't be selected:

irb(main):016:0> imap.list '', 'directory'
C: RUBY0012 LIST "" directory
S: * LIST (\Noselect \HasChildren) "/" "directory"
S: RUBY0012 OK List completed.

irb(main):015:0> imap.copy [1], 'directory'
C: RUBY0011 COPY 1 directory
S: RUBY0011 NO Mailbox isn't selectable: directory

The attached patch adds the response to Net::IMAP::ResponseError which allows us to behave intelligently:

$ cat imap_copy.rb 
require 'net/imap'

Net::IMAP.debug = true
imap = Net::IMAP.new 'localhost', 143
imap.login 'test', 'test'
imap.select 'INBOX'
uids = imap.search 'ALL'

begin
  imap.copy uids, 'no such mailbox'
  puts 'copy successful'
rescue Net::IMAP::NoResponseError => e
  raise unless e.response.data.code.name == 'TRYCREATE'
  imap.create 'no such mailbox'
  imap.copy uids, 'no such mailbox'
end
$ ruby imap_copy.rb 
S: * OK Dovecot ready.
[...]
C: RUBY0004 COPY 1 "no such mailbox"
S: RUBY0004 NO [TRYCREATE] Mailbox doesn't exist: no such mailbox
C: RUBY0005 CREATE "no such mailbox"
S: RUBY0005 OK Create completed.
C: RUBY0006 COPY 1 "no such mailbox"
S: RUBY0006 OK [COPYUID 1 64 1] Copy completed.


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next