Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Michael Stapelberg <michael+sup@stapelberg.de>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [sup-devel] [PATCH] Decode messages according to their Content-Transfer-Encoding
Date: Sat, 05 Jun 2010 00:17:54 +0200	[thread overview]
Message-ID: <1275689764-sup-3384@midna.zekjur.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 246 bytes --]

Hi,

quote of the commit message:
    Decode messages according to their Content-Transfer-Encoding
        
    This is necessary for MIME-messages (for example as part of multipart/signed)
    which are encoded in base64.

Best regards,
Michael

[-- Attachment #2: 0001-Decode-messages-according-to-their-Content-Transfer-.patch --]
[-- Type: application/octet-stream, Size: 1433 bytes --]

From bf86e61b22783776e8b9df4f31c59157f3222af1 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Sat, 5 Jun 2010 00:13:54 +0200
Subject: [PATCH] Decode messages according to their Content-Transfer-Encoding

This is necessary for MIME-messages (for example as part of multipart/signed)
which are encoded in base64.
---
 lib/sup/message.rb |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 396f01a..b70bc6b 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -459,8 +459,21 @@ private
 
       chunks
     elsif m.header.content_type && m.header.content_type.downcase == "message/rfc822"
+      encoding = m.header["Content-Transfer-Encoding"]
       if m.body
-        payload = RMail::Parser.read(m.body)
+        body =
+        case encoding
+        when "base64"
+          m.body.unpack("m")[0]
+        when "quoted-printable"
+          m.body.unpack("M")[0]
+        when "7bit", "8bit", nil
+          m.body
+        else
+          raise EncodingUnsupportedError, encoding.inspect
+        end
+        body = body.normalize_whitespace
+        payload = RMail::Parser.read(body)
         from = payload.header.from.first ? payload.header.from.first.format : ""
         to = payload.header.to.map { |p| p.format }.join(", ")
         cc = payload.header.cc.map { |p| p.format }.join(", ")
-- 
1.7.1


[-- Attachment #3: 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-06-04 22:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04 22:17 Michael Stapelberg [this message]
2010-06-05  2:54 ` Rich Lane
2010-06-05 10:55   ` Michael Stapelberg
2010-06-07 15:55     ` Rich Lane

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=1275689764-sup-3384@midna.zekjur.net \
    --to=michael+sup@stapelberg.de \
    --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