From 70ab511c171700bc435978eb505d15022ee91084 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Mon, 19 May 2008 14:11:11 -0700 Subject: [PATCH] bugfix: gpg signing failures because when no trailing newlines when :edit_signature was false, and a non-empty signature file was used, message bodies didn't end in a newline. for some reason GPG produces signature output that assumes a trailing newline, even if you don't have one. so, now we force one if it ain't there. --- lib/sup/crypto.rb | 2 ++ lib/sup/modes/edit-message-mode.rb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb index ee06958..f596c89 100644 --- a/lib/sup/crypto.rb +++ b/lib/sup/crypto.rb @@ -150,6 +150,8 @@ private ["Can't find gpg binary in path."] end + ## 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/, "") end diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb index b2b60eb..7fdb4f1 100644 --- a/lib/sup/modes/edit-message-mode.rb +++ b/lib/sup/modes/edit-message-mode.rb @@ -305,8 +305,9 @@ protected m = RMail::Message.new m.header["Content-Type"] = "text/plain; charset=#{$encoding}" m.body = @body.join - m.body = m.body m.body += sig_lines.join("\n") unless $config[:edit_signature] + ## body must end in a newline or GPG signatures will be WRONG! + m.body += "\n" unless m.body =~ /\n\Z/ ## there are attachments, so wrap body in an attachment of its own unless @attachments.empty? -- 2.45.2