Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Daniel Schoepe <daniel.schoepe@googlemail.com>
To: sup-devel@rubyforge.org
Subject: [sup-devel] [PATCH] Fix crash when sending signed/encrypted messages with attachments
Date: Fri, 30 Jul 2010 01:30:19 +0200	[thread overview]
Message-ID: <1280446020-sup-4762@gilead> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 249 bytes --]

Currently, when trying to send an encrypted or signed message with an
attachment, sup crashes, since it tries to .pack('m') the body of a
multipart message, which is an array of RMail::Messages and thus
crashes.

The attached patch should fix that.

[-- Attachment #1.1.2: 0001-Fix-crash-when-sending-signed-encrypted-messages-wit.patch --]
[-- Type: application/octet-stream, Size: 1415 bytes --]

From 27c8180771977d0c4e76f403813134d345d28ec8 Mon Sep 17 00:00:00 2001
From: Daniel Schoepe <daniel.schoepe@googlemail.com>
Date: Fri, 30 Jul 2010 01:11:38 +0200
Subject: [PATCH] Fix crash when sending signed/encrypted messages with attachments

This fixes a crash where sup died due to a TypeError in
EditMessageMode.build_message.
---
 lib/sup/modes/edit-message-mode.rb |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index 89b9da0..6939d7b 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -383,9 +383,15 @@ protected
     if @crypto_selector && @crypto_selector.val != :none
       from_email = Person.from_address(@header["From"]).email
       to_email = [@header["To"], @header["Cc"], @header["Bcc"]].flatten.compact.map { |p| Person.from_address(p).email }
-      m.header["Content-Transfer-Encoding"] = 'base64'
-      m.body = [m.body].pack('m')
-
+      if @attachments.empty?
+        m.body = [m.body].pack('m')
+        m.header["Content-Transfer-Encoding"] = 'base64'
+      else
+        old_m = m.part(0)
+        old_m.body = [old_m.body].pack('m')
+        old_m.header["Content-Transfer-Encoding"] = 'base64'
+        m.body[0] = old_m
+      end
       m = CryptoManager.send @crypto_selector.val, from_email, to_email, m
     end
 
-- 
1.7.1


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

                 reply	other threads:[~2010-07-29 23:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1280446020-sup-4762@gilead \
    --to=daniel.schoepe@googlemail.com \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox