* [sup-devel] [PATCH] inline-gpg: call text_to_chunks on the text before/after the GPG part
@ 2010-06-22 15:40 Michael Stapelberg
2010-07-03 2:33 ` Rich Lane
0 siblings, 1 reply; 2+ messages in thread
From: Michael Stapelberg @ 2010-06-22 15:40 UTC (permalink / raw)
To: sup-devel
[-- 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [sup-devel] [PATCH] inline-gpg: call text_to_chunks on the text before/after the GPG part
2010-06-22 15:40 [sup-devel] [PATCH] inline-gpg: call text_to_chunks on the text before/after the GPG part Michael Stapelberg
@ 2010-07-03 2:33 ` Rich Lane
0 siblings, 0 replies; 2+ messages in thread
From: Rich Lane @ 2010-07-03 2:33 UTC (permalink / raw)
To: Michael Stapelberg; +Cc: sup-devel
Applied to master.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-03 2:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-22 15:40 [sup-devel] [PATCH] inline-gpg: call text_to_chunks on the text before/after the GPG part Michael Stapelberg
2010-07-03 2:33 ` Rich Lane
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox