lib/sup/modes/edit_message_mode.rb in sup-0.14.0 vs lib/sup/modes/edit_message_mode.rb in sup-0.14.1

- old
+ new

@@ -176,11 +176,11 @@ ## hook for subclasses. i hate this style of programming. def handle_new_text header, body; end def edit_message_or_field - lines = DECORATION_LINES + @selectors.size + lines = (@selectors.empty? ? 0 : DECORATION_LINES) + @selectors.size if lines > curpos return elsif (curpos - lines) >= @header_lines.length edit_message else @@ -487,11 +487,11 @@ if not HookManager.run "sendmail", :message => m, :account => acct warn "Sendmail hook was not successful" return false end else - IO.popen(acct.sendmail, "w") { |p| p.puts m } + IO.popen(acct.sendmail, "w:UTF-8") { |p| p.puts m } raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $? == 0 end SentManager.write_sent_message(date, from_email) { |f| f.puts sanitize_body(m.to_s) } BufferManager.kill_buffer buffer @@ -515,19 +515,23 @@ m.header["Content-Type"] = "text/plain; charset=#{$encoding}" m.body = @body.join("\n") m.body += "\n" + sig_lines.join("\n") unless @sig_edited ## body must end in a newline or GPG signatures will be WRONG! m.body += "\n" unless m.body =~ /\n\Z/ + m.body = m.body.fix_encoding! ## there are attachments, so wrap body in an attachment of its own unless @attachments.empty? body_m = m body_m.header["Content-Disposition"] = "inline" m = RMail::Message.new m.add_part body_m - @attachments.each { |a| m.add_part a } + @attachments.each do |a| + a.body = a.body.fix_encoding! if a.body.kind_of? String + m.add_part a + end end ## do whatever crypto transformation is necessary if @crypto_selector && @crypto_selector.val != :none from_email = Person.from_address(@header["From"]).email @@ -545,12 +549,12 @@ @header.each do |k, v| next if v.nil? || v.empty? m.header[k] = case v when String - k.match(/subject/i) ? mime_encode_subject(v) : mime_encode_address(v) + (k.match(/subject/i) ? mime_encode_subject(v) : mime_encode_address(v)).fix_encoding! when Array - v.map { |v| mime_encode_address v }.join ", " + (v.map { |v| mime_encode_address v }.join ", ").fix_encoding! end end m.header["Date"] = date.rfc2822 m.header["Message-Id"] = @message_id