[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] Mysterious nil errors



Here are some patches that correct some mysterious Nil errors.  I don't
know what messages caused them or if they're correct.  I don't really want
them to go in, but I would like to know further directions.

diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index ebc73fc..ec12039 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -436,12 +436,12 @@ private
         end
 
       unless chunks
-        sibling_types = m.body.map { |p| p.header.content_type }
+        sibling_types = m.body.map { |p| p.header["content_type"] ? p.header.content_type : "application/unknown" }
         chunks = m.body.map { |p| message_to_chunks p, encrypted, sibling_types }.flatten.compact
       end
 
       chunks
-    elsif m.header.content_type && m.header.content_type.downcase == "message/rfc822"
+    elsif m.header["content_type"] && m.header.content_type && m.header.content_type.downcase == "message/rfc822"
       if m.body
         payload = RMail::Parser.read(m.body)
         from = payload.header.from.first ? payload.header.from.first.format : ""
@@ -458,7 +458,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"] && m.header.content_type && m.header.content_type.downcase == "application/pgp" && m.body
       ## 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
@@ -503,7 +503,7 @@ private
         # Lowercase the filename because searches are easier that way 
         @attachments.push filename.downcase unless filename =~ /^sup-attachment-/
         add_label :attachment unless filename =~ /^sup-attachment-/
-        content_type = (m.header.content_type || "application/unknown").downcase # sometimes RubyMail gives us nil
+        content_type = (m.header["content_type"] && m.header.content_type || "application/unknown").downcase # sometimes RubyMail gives us nil
         [Chunk::Attachment.new(content_type, filename, m, sibling_types)]
 
       ## otherwise, it's body text
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
index f53001f..84399d3 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -231,7 +231,7 @@ EOS
     old_cursor_thread = cursor_thread
     @mutex.synchronize do
       ## let's see you do THIS in python
-      @threads = @ts.threads.select { |t| !@hidden_threads[t] }.sort_by { |t| [t.date, t.first.id] }.reverse
+      @threads = @ts.threads.select { |t| !@hidden_threads[t] && t.first }.sort_by { |t| [t.date, t.first.id] }.reverse
       @size_widgets = @threads.map { |t| size_widget_for_thread t }
       @size_widget_width = @size_widgets.max_of { |w| w.display_length }
       @date_widgets = @threads.map { |t| date_widget_for_thread t }
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel