]> git.cworth.org Git - sup/commitdiff
bugfix: gpg signing failures because when no trailing newlines
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Mon, 19 May 2008 21:11:11 +0000 (14:11 -0700)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Mon, 19 May 2008 21:11:11 +0000 (14:11 -0700)
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
lib/sup/modes/edit-message-mode.rb

index ee0695862415939120b262d4d4cec2e1ec2f214e..f596c8964f9c933e86890a66e251d6ba23c18193 100644 (file)
@@ -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
index b2b60eb043290201b7aecbca6fa45cb4628a5012..7fdb4f1991c496dbd52a4c0eef92c785095b88e5 100644 (file)
@@ -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?