From eda1db3a81cec8839dd8c31b92439f9dcf6b5550 Mon Sep 17 00:00:00 2001 From: wmorgan Date: Mon, 16 Apr 2007 22:58:59 +0000 Subject: [PATCH] better rubymail usage git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@380 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- lib/sup/message.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/sup/message.rb b/lib/sup/message.rb index 4b94482..da3d0af 100644 --- a/lib/sup/message.rb +++ b/lib/sup/message.rb @@ -263,22 +263,22 @@ EOS private - ## everything RubyMail-specific goes here. + ## (almost) everything rmail-specific goes here def message_to_chunks m - ret = [] << + if m.multipart? + m.body.map { |p| message_to_chunks p }.flatten.compact + else case m.header.content_type when "text/plain", nil m.body && body = m.decode or raise MessageFormatError, "For some bizarre reason, RubyMail was unable to parse this message." - text_to_chunks body.normalize_whitespace.split("\n") + text_to_chunks(body.normalize_whitespace.split("\n")) when /^multipart\// - nil + [] else disp = m.header["Content-Disposition"] || "" - Attachment.new m.header.content_type, disp.gsub(/[\s\n]+/, " "), m + [Attachment.new(m.header.content_type, disp.gsub(/[\s\n]+/, " "), m)] end - - m.each_part { |p| ret << message_to_chunks(p) } if m.multipart? - ret.compact.flatten + end end ## parse the lines of text into chunk objects. the heuristics here -- 2.45.2