[gmime/gmime-2-4] Decode content of the pgp/mime part before decrypting
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime/gmime-2-4] Decode content of the pgp/mime part before decrypting
- Date: Sat, 5 Nov 2011 19:07:21 +0000 (UTC)
commit e8464df381eea5d8f35926da9b25196e39a0a4fb
Author: Jeffrey Stedfast <fejj gnome org>
Date: Sat Nov 5 15:06:20 2011 -0400
Decode content of the pgp/mime part before decrypting
2011-11-05 Jeffrey Stedfast <fejj gnome org>
* gmime/gmime-multipart-encrypted.c
(g_mime_multipart_encrypted_decrypt): Need to decode the content
of the application/octet-stream part containing the encrypted
payload as it may have a non-7bit Content-Transfer-Encoding.
ChangeLog | 7 +++++++
gmime/gmime-multipart-encrypted.c | 33 +++++++++++++++++++++++++++++++--
2 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c307573..34d02ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2011-11-05 Jeffrey Stedfast <fejj gnome org>
+ * gmime/gmime-multipart-encrypted.c
+ (g_mime_multipart_encrypted_decrypt): Need to decode the content
+ of the application/octet-stream part containing the encrypted
+ payload as it may have a non-7bit Content-Transfer-Encoding.
+
+2011-11-05 Jeffrey Stedfast <fejj gnome org>
+
* README: Bumped version
* configure.in: Bumped version to 2.4.27
diff --git a/gmime/gmime-multipart-encrypted.c b/gmime/gmime-multipart-encrypted.c
index d6cc236..9a0a4fb 100644
--- a/gmime/gmime-multipart-encrypted.c
+++ b/gmime/gmime-multipart-encrypted.c
@@ -28,7 +28,7 @@
#include "gmime-multipart-encrypted.h"
#include "gmime-stream-filter.h"
-#include "gmime-filter-crlf.h"
+#include "gmime-filter-basic.h"
#include "gmime-filter-from.h"
#include "gmime-filter-crlf.h"
#include "gmime-stream-mem.h"
@@ -312,6 +312,33 @@ g_mime_multipart_encrypted_encrypt (GMimeMultipartEncrypted *mpe, GMimeObject *c
}
+static GMimeStream *
+g_mime_data_wrapper_get_decoded_stream (GMimeDataWrapper *wrapper)
+{
+ GMimeStream *decoded_stream;
+ GMimeFilter *decoder;
+
+ g_mime_stream_reset (wrapper->stream);
+
+ switch (wrapper->encoding) {
+ case GMIME_CONTENT_ENCODING_BASE64:
+ case GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE:
+ case GMIME_CONTENT_ENCODING_UUENCODE:
+ decoder = g_mime_filter_basic_new (wrapper->encoding, FALSE);
+ decoded_stream = g_mime_stream_filter_new (wrapper->stream);
+ g_mime_stream_filter_add (GMIME_STREAM_FILTER (decoded_stream), decoder);
+ g_object_unref (decoder);
+ break;
+ default:
+ decoded_stream = wrapper->stream;
+ g_object_ref (wrapper->stream);
+ break;
+ }
+
+ return decoded_stream;
+}
+
+
/**
* g_mime_multipart_encrypted_decrypt:
* @mpe: multipart/encrypted object
@@ -399,7 +426,7 @@ g_mime_multipart_encrypted_decrypt (GMimeMultipartEncrypted *mpe, GMimeCipherCon
/* get the ciphertext stream */
wrapper = g_mime_part_get_content_object (GMIME_PART (encrypted));
- ciphertext = g_mime_data_wrapper_get_stream (wrapper);
+ ciphertext = g_mime_data_wrapper_get_decoded_stream (wrapper);
g_mime_stream_reset (ciphertext);
stream = g_mime_stream_mem_new ();
@@ -411,6 +438,7 @@ g_mime_multipart_encrypted_decrypt (GMimeMultipartEncrypted *mpe, GMimeCipherCon
/* get the cleartext */
if (!(sv = g_mime_cipher_context_decrypt (ctx, ciphertext, filtered_stream, err))) {
g_object_unref (filtered_stream);
+ g_object_unref (ciphertext);
g_object_unref (stream);
return NULL;
@@ -418,6 +446,7 @@ g_mime_multipart_encrypted_decrypt (GMimeMultipartEncrypted *mpe, GMimeCipherCon
g_mime_stream_flush (filtered_stream);
g_object_unref (filtered_stream);
+ g_object_unref (ciphertext);
g_mime_stream_reset (stream);
parser = g_mime_parser_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]