From: Michael Stapelberg <michael+sup@stapelberg.de>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [sup-devel] [PATCH] inline-gpg: call text_to_chunks on the text before/after the GPG part
Date: Tue, 22 Jun 2010 17:40:45 +0200 [thread overview]
Message-ID: <1277221190-sup-946@midna.zekjur.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 259 bytes --]
Hi,
quote from the commit message:
inline-gpg: call text_to_chunks on the text before/after the GPG part
This is necessary for stupid mailers which produce TOFU mails
containing unquoted inline gpg mails *argh*.
Best regards,
Michael
[-- Attachment #2: 0001-inline-gpg-call-text_to_chunks-on-the-text-before-af.patch --]
[-- Type: application/octet-stream, Size: 2719 bytes --]
From 3d2fa2584f3a4f836f1f9ed15b25e641e7560503 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Tue, 22 Jun 2010 17:30:37 +0200
Subject: [PATCH] inline-gpg: call text_to_chunks on the text before/after the GPG part
This is necessary for stupid mailers which produce TOFU mails
containing unquoted inline gpg mails *argh*.
---
lib/sup/message.rb | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index b70bc6b..472d007 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -32,7 +32,8 @@ class Message
GPG_SIGNED_END = "-----END PGP SIGNED MESSAGE-----"
GPG_START = "-----BEGIN PGP MESSAGE-----"
GPG_END = "-----END PGP MESSAGE-----"
- GPG_SIG_END = "-----BEGIN PGP SIGNATURE-----"
+ GPG_SIG_START = "-----BEGIN PGP SIGNATURE-----"
+ GPG_SIG_END = "-----END PGP SIGNATURE-----"
MAX_SIG_DISTANCE = 15 # lines from the end
DEFAULT_SUBJECT = ""
@@ -572,23 +573,40 @@ private
msg.body = gpg.join("\n")
body = Iconv.easy_decode(encoding_to, encoding_from, body)
- sig = body.split("\n").between(GPG_SIGNED_START, GPG_SIG_END)
+ lines = body.split("\n")
+ sig = lines.between(GPG_SIGNED_START, GPG_SIG_START)
+ startidx = lines.index(GPG_SIGNED_START)
+ endidx = lines.index(GPG_SIG_END)
+ before = startidx != 0 ? lines[0 .. startidx-1] : []
+ after = endidx ? lines[endidx+1 .. lines.size] : []
+
payload = RMail::Message.new
payload.body = sig[1, sig.size-2].join("\n")
- return [CryptoManager.verify(nil, msg, false), message_to_chunks(payload)].flatten.compact
+ return [text_to_chunks(before, false),
+ CryptoManager.verify(nil, msg, false),
+ message_to_chunks(payload),
+ text_to_chunks(after, false)].flatten.compact
end
gpg = lines.between(GPG_START, GPG_END)
if !gpg.empty?
msg = RMail::Message.new
msg.body = gpg.join("\n")
+
+ startidx = lines.index(GPG_START)
+ before = startidx != 0 ? lines[0 .. startidx-1] : []
+ after = lines[lines.index(GPG_END)+1 .. lines.size]
+
notice, sig, decryptedm = CryptoManager.decrypt msg, true
- if decryptedm # managed to decrypt
+ chunks = if decryptedm # managed to decrypt
children = message_to_chunks(decryptedm, true)
- return [notice, sig].compact + children
+ [notice, sig].compact + children
else
- return [notice]
+ [notice]
end
+ return [text_to_chunks(before, false),
+ chunks,
+ text_to_chunks(after, false)].flatten.compact
end
end
--
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
next reply other threads:[~2010-06-22 15:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-22 15:40 Michael Stapelberg [this message]
2010-07-03 2:33 ` 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=1277221190-sup-946@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