commit 07f0be019f60901594b6a1c0e0d042bea52367d7
parent f8ca3a0d051d0e3158383c0dd3b289a2eeb0f1d4
Author: Gaudenz Steinlin <gaudenz@soziologie.ch>
Date: Tue, 12 Oct 2010 23:25:28 +0200
Monkey patch RMails MIME-Version header handling
RMail automagically adds MIME-Version headers to messages on
serialization. Sup uses RMail::Message object to represent parts of
multipart messages. Adding headers to these parts breaks gpg signatures.
The MIME-Version header is only needed in the outermost message. There
it's added manually.
Diffstat:
6 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -5,6 +5,7 @@ require 'thread'
require 'fileutils'
require 'gettext'
require 'curses'
+require 'rmail'
begin
require 'fastthread'
rescue LoadError
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -207,7 +207,7 @@ private
## here's where we munge rmail output into the format that signed/encrypted
## PGP/GPG messages should be
def format_payload payload
- payload.to_s.gsub(/(^|[^\r])\n/, "\\1\r\n").gsub(/^MIME-Version: .*\r\n/, "")
+ payload.to_s.gsub(/(^|[^\r])\n/, "\\1\r\n")
end
# logic is:
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
@@ -1,4 +1,3 @@
-require 'rmail'
require 'uri'
module Redwood
diff --git a/lib/sup/mbox.rb b/lib/sup/mbox.rb
@@ -1,4 +1,3 @@
-require 'rmail'
require 'uri'
require 'set'
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
@@ -1,7 +1,6 @@
require 'tempfile'
require 'socket' # just for gethostname!
require 'pathname'
-require 'rmail'
module Redwood
@@ -428,6 +427,7 @@ protected
m.header["Message-Id"] = @message_id
m.header["User-Agent"] = "Sup/#{Redwood::VERSION}"
m.header["Content-Transfer-Encoding"] ||= '8bit'
+ m.header["MIME-Version"] = "1.0" if m.multipart?
m
end
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -98,6 +98,19 @@ module RMail
a
end
end
+
+ class Serialize
+ ## Don't add MIME-Version headers on serialization. Sup sometimes want's to serialize
+ ## message parts where these headers are not needed and messing with the message on
+ ## serialization breaks gpg signatures. The commented section shows the original RMail
+ ## code.
+ def calculate_boundaries(message)
+ calculate_boundaries_low(message, [])
+ # unless message.header['MIME-Version']
+ # message.header['MIME-Version'] = "1.0"
+ # end
+ end
+ end
end
class Range