lib/sup/message_chunks.rb in sup-1.0 vs lib/sup/message_chunks.rb in sup-1.1
- old
+ new
@@ -126,11 +126,20 @@
"For some bizarre reason, RubyMail was unable to parse this attachment.\n"
end
text = case @content_type
when /^text\/plain\b/
- @raw_content.force_encoding(encoded_content.charset || 'US-ASCII')
+ if /^UTF-7$/i =~ encoded_content.charset
+ @raw_content.decode_utf7
+ else
+ begin
+ charset = Encoding.find(encoded_content.charset || 'US-ASCII')
+ rescue ArgumentError
+ charset = 'US-ASCII'
+ end
+ @raw_content.force_encoding(charset)
+ end
else
HookManager.run "mime-decode", :content_type => @content_type,
:filename => lambda { write_to_disk },
:charset => encoded_content.charset,
:sibling_types => sibling_types
@@ -272,38 +281,37 @@
end
class EnclosedMessage
attr_reader :lines
def initialize from, to, cc, date, subj
- @from = from ? "unknown sender" : from.full_address
- @to = to ? "" : to.map { |p| p.full_address }.join(", ")
- @cc = cc ? "" : cc.map { |p| p.full_address }.join(", ")
- if date
- @date = date.rfc822
- else
- @date = ""
- end
-
+ @from = !from ? "unknown sender" : from.full_address
+ @to = !to ? "" : to.map { |p| p.full_address }.join(", ")
+ @cc = !cc ? "" : cc.map { |p| p.full_address }.join(", ")
+ @date = !date ? "" : date.rfc822
@subj = subj
-
- @lines = "\nFrom: #{from}\n"
- @lines += "To: #{to}\n"
- if !cc.empty?
- @lines += "Cc: #{cc}\n"
- end
- @lines += "Date: #{date}\n"
- @lines += "Subject: #{subj}\n\n"
+ @lines = [
+ "From: #{@from}",
+ "To: #{@to}",
+ "Cc: #{@cc}",
+ "Date: #{@date}",
+ "Subject: #{@subj}"
+ ]
+ @lines.delete_if{ |line| line == 'Cc: ' }
end
def inlineable?; false end
def quotable?; false end
def expandable?; true end
def indexable?; true end
def initial_state; :closed end
def viewable?; false end
def patina_color; :generic_notice_patina_color end
- def patina_text; "Begin enclosed message sent on #{@date}" end
+ def patina_text
+ "Begin enclosed message" + (
+ @date == "" ? "" : " sent on #{@date}"
+ )
+ end
def color; :quote_color end
end
class CryptoNotice