Bug #5163

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

Added by art lussos over 3 years ago. Updated over 3 years ago.

[ruby-core:38820]
Status:Closed
Priority:Normal
Assignee:Shugo Maeda
ruby -v:ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] Backport:

Description

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

Associated revisions

Revision 33001
Added by Shugo Maeda over 3 years ago

  • lib/net/imap.rb (msg_att): accepts extra space before ')'. based on the patch by art lussos. [Bug #5163]

Revision 33001
Added by Shugo Maeda over 3 years ago

  • lib/net/imap.rb (msg_att): accepts extra space before ')'. based on the patch by art lussos. [Bug #5163]

History

#1 Updated by Shugo Maeda over 3 years ago

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

#2 Updated by Shugo Maeda over 3 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r33001.
art , thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/net/imap.rb (msg_att): accepts extra space before ')'. based on the patch by art lussos. [Bug #5163]

Also available in: Atom PDF