X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fmessage.rb;h=0ee46fb25d7ecbb97807910c9fa0785337bccc2c;hb=e08e96a37edffd57ffb1bc596e4420866ec2faf4;hp=944dd88947207295e143fb3df1bf0c131ba83511;hpb=db17951de14da8f32d51441589fd736d77bf7379;p=sup diff --git a/lib/sup/message.rb b/lib/sup/message.rb index 944dd88..0ee46fb 100644 --- a/lib/sup/message.rb +++ b/lib/sup/message.rb @@ -64,7 +64,7 @@ class Message end def parse_header header - header.each { |k, v| header[k.downcase] = v } + header.keys.each { |k| header[k.downcase] = header[k] } # canonicalize fakeid = nil fakename = nil @@ -78,10 +78,10 @@ class Message @from = if header["from"] - PersonManager.person_for header["from"] + Person.from_address header["from"] else fakename = "Sup Auto-generated Fake Sender " - PersonManager.person_for fakename + Person.from_address fakename end Redwood::log "faking message-id for message from #@from: #{id}" if fakeid @@ -105,9 +105,9 @@ class Message end @subj = header.member?("subject") ? header["subject"].gsub(/\s+/, " ").gsub(/\s+$/, "") : DEFAULT_SUBJECT - @to = PersonManager.people_for header["to"] - @cc = PersonManager.people_for header["cc"] - @bcc = PersonManager.people_for header["bcc"] + @to = Person.from_address_list header["to"] + @cc = Person.from_address_list header["cc"] + @bcc = Person.from_address_list header["bcc"] ## before loading our full header from the source, we can actually ## have some extra refs set by the UI. (this happens when the user @@ -117,10 +117,10 @@ class Message @refs = (@refs + refs).uniq @replytos = (header["in-reply-to"] || "").scan(/<(.+?)>/).map { |x| sanitize_message_id x.first } - @replyto = PersonManager.person_for header["reply-to"] + @replyto = Person.from_address header["reply-to"] @list_address = if header["list-post"] - @list_address = PersonManager.person_for header["list-post"].gsub(/^$/, "") + @list_address = Person.from_address header["list-post"].gsub(/^$/, "") else nil end @@ -391,7 +391,7 @@ private elsif m.header.content_type == "message/rfc822" payload = RMail::Parser.read(m.body) from = payload.header.from.first - from_person = from ? PersonManager.person_for(from.format) : nil + from_person = from ? Person.from_address(from.format) : nil [Chunk::EnclosedMessage.new(from_person, payload.to_s)] + message_to_chunks(payload, encrypted) else @@ -434,11 +434,10 @@ private end def self.convert_from body, charset - charset = "utf-8" if charset =~ /UTF_?8/i begin raise MessageFormatError, "RubyMail decode returned a null body" unless body return body unless charset - Iconv.iconv($encoding + "//IGNORE", charset, body + " ").join[0 .. -2] + Iconv.easy_decode($encoding, charset, body) rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::IllegalSequence, MessageFormatError => e Redwood::log "warning: error (#{e.class.name}) decoding message body from #{charset}: #{e.message}" File.open(File.join(BASE_DIR,"unable-to-decode.txt"), "w") { |f| f.write body }