Net::IMAP::ResponseParseError

Hello,

Net::IMAP seems to chock on some IMAP strings.

% ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin10.0]

For example:

require ‘net/imap’

imap = Net::IMAP.new(‘localhost’, 1143 )
imap.login(‘user’, ‘password’)
imap.examine(‘INBOX’)
imap.search([“ALL”]).each do |message_id|
envelope = imap.fetch(message_id, “ENVELOPE”)[0].attr[“ENVELOPE”]
puts “#{envelope.subject}”
end

ruby/1.8/net/imap.rb:3129:in parse_error': unknown token - "\"Lua," (Net::IMAP::ResponseParseError) from ruby/1.8/net/imap.rb:3074:innext_token’
from ruby/1.8/net/imap.rb:2991:in lookahead' from ruby/1.8/net/imap.rb:2889:innstring’
from ruby/1.8/net/imap.rb:2086:in `envelope’

The over-the-wire protocol exchange looks like the following:

c: RUBY1300 FETCH 1297 ENVELOPE
s: * 1297 fetch (envelope (“Wed, 13 Oct 1999 12:44:07 +0000” “Lua,
strfind \0-quirk/bug” ((“Jon Kleiser” nil “jon.kleiser” “usit.uio.no”))
((“Jon Kleiser” nil “jon.kleiser” “usit.uio.no”)) ((“Jon Kleiser” nil
“jon.kleiser” “usit.uio.no”)) ((nil nil “lua” “tecgraf.puc-rio.br”))
((“Lua discussion list” nil “lua-l” “tecgraf.puc-rio.br”)) nil nil
“<[email protected][129.240.92.61]>”))

Note the envelope subject:

“Lua, strfind \0-quirk/bug”

Notice the literal “\0”. As there is no escape sequences in IMAP, \0
should be treated as a regular string.

On Feb 21, 2012, at 12:53 AM, Petite A. wrote:

Hello,

Net::IMAP seems to chock on some IMAP strings.

% ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin10.0]

Did you try with a modern ruby? There have been many improvements to
Net::IMAP over the last two years.

On Feb 22, 2012, at 11:22 PM, Eric H. wrote:

Did you try with a modern ruby? There have been many improvements to Net::IMAP
over the last two years.

Same issue in 1.9.3p0.

% ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]

ruby/1.9.1/net/imap.rb:3277:in parse_error': unknown token - "\"Lua," (Net::IMAP::ResponseParseError) from ruby/1.9.1/net/imap.rb:3222:innext_token’
from ruby/1.9.1/net/imap.rb:3139:in lookahead' from ruby/1.9.1/net/imap.rb:3037:innstring’
from ruby/1.9.1/net/imap.rb:2225:in envelope' from ruby/1.9.1/net/imap.rb:2212:inenvelope_data’

On Feb 23, 2012, at 12:37 AM, Ryan D. wrote:

“Lua, strfind \0-quirk/bug”

Notice the literal “\0”. As there is no escape sequences in IMAP, \0 should be
treated as a regular string.

http://tools.ietf.org/html/rfc3501#page-17

In this case, it’s just mean to be the literal \0. That’s all.

On Feb 21, 2012, at 00:53 , Petite A. wrote:

Note the envelope subject:

“Lua, strfind \0-quirk/bug”

Notice the literal “\0”. As there is no escape sequences in IMAP, \0 should be
treated as a regular string.

http://tools.ietf.org/html/rfc3501#page-17

8-bit textual and binary mail is supported through the use of a
[MIME-IMB] content transfer encoding. IMAP4rev1 implementations MAY
transmit 8-bit or multi-octet characters in literals, but SHOULD do
so only when the [CHARSET] is identified.

Although a BINARY body encoding is defined, unencoded binary strings
are not permitted. A “binary string” is any string with NUL
characters. Implementations MUST encode binary data into a textual
form, such as BASE64, before transmitting the data. A string with an
excessive amount of CTL characters MAY also be considered to be
binary.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs