Monkeypatch imap class error handling


I have a broken IMAP-Server which violates the imap protocol. I want
gladly to migrate my mail and switch the server. I worked with the ruby
larch program to overcome the discapabilities of my actual server.

The only thing which is left to do is to properly escape " and ( )
characters in the mail envelope. I had to do some kind of monkey patch
here I think, because I had to look, whether the character is a envelope
separator or if its just malencoded in the subject attribute (one could
use the comma to verify that).

My server throws

/usr/lib/ruby/1.9.1/net/imap.rb:3277:in parse_error': unexpected token QUOTED (expected SPACE) (Net::IMAP::ResponseParseError) from /usr/lib/ruby/1.9.1/net/imap.rb:3129:inmatch’
from /usr/lib/ruby/1.9.1/net/imap.rb:2226:in envelope' from /usr/lib/ruby/1.9.1/net/imap.rb:2212:inenvelope_data’
from /usr/lib/ruby/1.9.1/net/imap.rb:2187:in msg_att' from /usr/lib/ruby/1.9.1/net/imap.rb:2167:innumeric_response’
from /usr/lib/ruby/1.9.1/net/imap.rb:2109:in
response_untagged' from /usr/lib/ruby/1.9.1/net/imap.rb:2089:inresponse’
from /usr/lib/ruby/1.9.1/net/imap.rb:2015:in parse' from /usr/lib/ruby/1.9.1/net/imap.rb:1166:inget_response’
from /usr/lib/ruby/1.9.1/net/imap.rb:1074:in
receive_responses' from /usr/lib/ruby/1.9.1/net/imap.rb:1060:inblock in

on fetch envelope. Could you help me with that? Where to start?

kind regards,