Issue #5163 has been updated by Shugo Maeda.

Status changed from Open to Assigned
Assignee set to Shugo Maeda


----------------------------------------
Bug #5163: (Net::IMAP::ResponseParseError) unknown attribute `)'
http://redmine.ruby-lang.org/issues/5163

Author: art  lussos
Status: Assigned
Priority: Normal
Assignee: Shugo Maeda
Category: 
Target version: 
ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] 


Every now and then we get the following ResponseParseError.

(Net::IMAP::ResponseParseError) unknown attribute `)'

Full Trace:
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:3235:in `parse_error'
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:2159:in `msg_att'
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:2125:in `numeric_response'
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:2067:in `response_untagged'
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:2047:in `response'
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:1973:in `parse'
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:1124:in `get_response'
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:1036:in `receive_responses'
.....rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/imap.rb:1023:in `block in initialize'

What is happening is that some mail servers are sending down a space in front of the closing ")".

What I propose is that when we get a "T_SPACE", instead of looking ahead, we just start another loop.

def msg_att
        match(T_LPAR)
        attr = {}
        while true
          token = lookahead

          case token.symbol
          when T_RPAR
            shift_token
            break
          when T_SPACE
            shift_token

           # CHANGE CHANGE CHANGE CHANGE
            #token = lookahead
            next
          end

          case token.value
          when /\A(?:ENVELOPE)\z/ni
            name, val = envelope_data
          when /\A(?:FLAGS)\z/ni
            name, val = flags_data
          when /\A(?:INTERNALDATE)\z/ni
            name, val = internaldate_data
          when /\A(?:RFC822(?:\.HEADER|\.TEXT)?)\z/ni
            name, val = rfc822_text
          when /\A(?:RFC822\.SIZE)\z/ni
            name, val = rfc822_size
          when /\A(?:BODY(?:STRUCTURE)?)\z/ni
            name, val = body_data
          when /\A(?:UID)\z/ni
            name, val = uid_data
          else
            parse_error("unknown attribute `%s'", token.value)
          end
          attr[name] = val
        end
        return attr
      end


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