From: Petite Abeille Date: 2012-02-21T17:53:09+09:00 Subject: 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:in `next_token' from ruby/1.8/net/imap.rb:2991:in `lookahead' from ruby/1.8/net/imap.rb:2889:in `nstring' 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 "")) 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.