Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: "Edward Z. Yang" <ezyang@MIT.EDU>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [sup-devel] Mysterious nil errors
Date: Tue, 09 Mar 2010 23:50:23 -0500	[thread overview]
Message-ID: <1268196562-sup-1692@ezyang> (raw)

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


             reply	other threads:[~2010-03-10  4:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-10  4:50 Edward Z. Yang [this message]
2010-03-10  4:52 ` Edward Z. Yang
2010-03-10  6:43   ` Tero Tilus
2010-03-10 17:24 ` Rich Lane
2010-03-10 17:40   ` Edward Z. Yang
2010-03-10 17:59     ` Rich Lane
2010-03-10 18:06       ` Edward Z. Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1268196562-sup-1692@ezyang \
    --to=ezyang@mit.edu \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox