Subject: [sup-talk] Sup crashes when loading a message

From: Alex Shulgin <[email-masked]>
Date: Fri, 23 Dec 2011 17:31:08 +0200

Got this crash today:

--- NoMethodError from thread: periodic poll
undefined method `downcase' for nil:NilClass
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/rmail-1.0.0/lib/rmail/header.rb:537:in
`content_type'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/message.rb:427:in
`message_to_chunks'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/message.rb:427:in
`map'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/message.rb:427:in
`message_to_chunks'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/message.rb:259:in
`load_from_source!'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/message.rb:328:in
`build_from_source'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:158:in
`poll_from'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/mbox.rb:143:in
`poll'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:155:in
`poll_from'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:113:in
`do_poll'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:103:in
`each'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:103:in
`do_poll'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:102:in
`synchronize'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:102:in
`do_poll'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/util.rb:609:in
`send'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/util.rb:609:in
`method_missing'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/modes/poll-mode.rb:15:in
`poll'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:49:in
`poll_with_sources'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:68:in `poll'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:86:in
`start'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup.rb:78:in
`reporting_thread'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup.rb:76:in
`initialize'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup.rb:76:in `new'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup.rb:76:in
`reporting_thread'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/poll.rb:83:in
`start'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/util.rb:609:in
`send'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/lib/sup/util.rb:609:in
`method_missing'
/home/ash/.rvm/gems/ruby-1.8.7-p352/gems/sup-0.12.1/bin/sup:222
/home/ash/.rvm/gems/ruby-1.8.7-p352/bin/sup:19:in `load'
/home/ash/.rvm/gems/ruby-1.8.7-p352/bin/sup:19

Seems like rmail doesn't really like an empty "Content-Type: " header:

rmail/header.rb:
    def content_type(default = nil)
      if value = self['content-type']
	value.strip.split(/\s*;\s*/)[0].downcase  # <== crashes on value=""
      else
	if block_given?
          yield
        else
          default
        end
      end
    end

Adding (... || "") before downcase seems to help this crash.
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk