Subject: Re: [sup-talk] RMail chokes on broken headers

From: Mariano Mara <[email-masked]>
Date: Thu, 29 Oct 2009 20:02:46 -0300

2009/10/15 William Morgan <[email-masked]>

> Reformatted excerpts from Tero Tilus's message of 2009-10-12:
> > RMail looks abandoned.  Development is pretty much stalled.  No
> > functional changes since 2004-04-27.  None of the reported bugs have
> > been fixed.  Might it be worth to think about switching to another
> > mail lib?  TMail author's http://github.com/mikel/mail/ looks
> > promising.
>
> Yeah, this is certainly an option. But it seems like a lot of work. And
> every day our set of rmail workarounds grows more robust. :)
>
> Not to say I wouldn't accept a patch that magically did this all for me,
> of course.
> --

Hi there, I'm facing the same error as reported by Tero. I applied the
modifications he sent, however it's failing in another place and my total
ignorance of Ruby prevents me from fixing it. Would anyone be so kind to
suggest a workaround?

Below is the complete exception recorded.

TIA,
Mariano

--- NoMethodError from thread: poll after loading inbox
undefined method `downcase' for nil:NilClass
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/message.rb:502:in
`message_to_chunks'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/message.rb:435:in
`message_to_chunks'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/message.rb:435:in `map'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/message.rb:435:in
`message_to_chunks'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/message.rb:239:in
`load_from_source!'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/message.rb:335:in
`build_from_source'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/poll.rb:145:in
`each_message_from'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/maildir.rb:160:in `each'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/maildir.rb:157:in `upto'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/maildir.rb:157:in `each'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/util.rb:560:in `send'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/util.rb:560:in `__pass'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/util.rb:547:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/poll.rb:139:in
`each_message_from'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/poll.rb:93:in `do_poll'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/poll.rb:81:in `each'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/poll.rb:81:in `do_poll'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/poll.rb:80:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/poll.rb:80:in `do_poll'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/util.rb:520:in `send'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/util.rb:520:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/modes/poll-mode.rb:15:in `poll'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/poll.rb:48:in `poll'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/util.rb:520:in `send'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/util.rb:520:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/bin/sup:196
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup.rb:77:in `reporting_thread'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup.rb:75:in `initialize'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup.rb:75:in `new'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup.rb:75:in `reporting_thread'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/bin/sup:196
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/modes/thread-index-mode.rb:669:in
`call'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/modes/thread-index-mode.rb:669:in
`__unprotected_load_threads'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/modes/thread-index-mode.rb:610:in
`call'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/modes/thread-index-mode.rb:610:in
`load_n_threads_background'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup.rb:77:in `reporting_thread'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup.rb:75:in `initialize'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup.rb:75:in `new'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup.rb:75:in `reporting_thread'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/modes/thread-index-mode.rb:608:in
`load_n_threads_background'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/lib/sup/modes/thread-index-mode.rb:679:in
`__unprotected_load_threads'
(eval):12:in `load_threads'
/usr/lib/ruby/gems/1.8/gems/sup-0.9/bin/sup:196
/usr/bin/sup:19:in `load'
/usr/bin/sup:19
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Tero Tilus <[email-masked]>
Date: Tue, 13 Oct 2009 02:22:15 +0300

RMail::Header#content_type breaks when it encounters broken
Content-Type and takes sup-sync down with it

/usr/lib/ruby/gems/1.8/gems/rmail-1.0.0/lib/rmail/header.rb:537:in `content_type': undefined method `downcase' for nil:NilClass (NoMethodError)
        from /home/terotil/src/sup/lib/sup/message.rb:439:in `message_to_chunks'
        from /home/terotil/src/sup/lib/sup/message.rb:239:in `load_from_source!'
        from /home/terotil/src/sup/lib/sup/message.rb:335:in `build_from_source'
        from /home/terotil/src/sup/lib/sup/poll.rb:160:in `each_message_from'

Worked around it this way

diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index f9f87de..5ff3e48 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -436,7 +436,7 @@ private
       end
 
       chunks
-    elsif m.header.content_type && m.header.content_type.downcase == "message/rfc822"
+    elsif (m.header.content_type == "message/rfc822" rescue false) # rmail 1.0.0 may choke on broken content-type header, FIXME: fix rmail
       if m.body
         payload = RMail::Parser.read(m.body)
         from = payload.header.from.first ? payload.header.from.first.format : ""
@@ -456,7 +456,7 @@ private
         debug "no body for message/rfc822 enclosure; skipping"
         []
       end
-    elsif m.header.content_type && m.header.content_type.downcase == "application/pgp" && m.body
+    elsif (m.header.content_type.downcase == "application/pgp" rescue false) && m.body # rmail 1.0.0 may choke on broken content-type header, FIXME: fix rmail
       ## apparently some versions of Thunderbird generate encryped email that
       ## does not follow RFC3156, e.g. messages with X-Enigmail-Version: 0.95.0
       ## they have no MIME multipart and just set the body content type to

The problem itself is inside RMail.  I reported it.
http://rubyforge.org/tracker/index.php?func=detail&aid=27282&group_id=446&atid=1754

-- 
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: William Morgan <[email-masked]>
Date: Thu, 15 Oct 2009 06:11:36 -0700

Not to say I wouldn't accept a patch that magically did this all for me,
of course.
-- 
William <[email-masked]>
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Mariano Mara <[email-masked]>
Date: Sat, 31 Oct 2009 17:18:19 -0300

2009/10/30 William Morgan <[email-masked]>

> Reformatted excerpts from Mariano Mara's message of 2009-10-29:
> > modifications he sent, however it's failing in another place and my
> > total ignorance of Ruby prevents me from fixing it. Would anyone be so
> > kind to suggest a workaround?
>
> This is fixed in git master. Maybe I should release an 0.9.1.
> --

Thanks a lot! It would be great if you could release 0.9.1

Mariano

---

From: William Morgan <[email-masked]>
Date: Fri, 30 Oct 2009 14:50:41 -0700