From eebf9be69590771ec04c254ec6391237dee3622c Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 9 Nov 2004 17:10:26 +0000 Subject: Fix for bug #69241. 2004-11-08 Jeffrey Stedfast Fix for bug #69241. * camel-gpg-context.c (gpg_decrypt): We need to extract just the application/pgp-encrypted part from the multipart/encrypted that gets passed in. Added checks to verify that the input part is the correct type as well. Once we have the application/pgp-encrypted part, we need to use camel_data_wrapper_decode_to_stream() in case the part was encoded in any way. svn path=/trunk/; revision=27876 --- camel/camel-gpg-context.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'camel/camel-gpg-context.c') diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 5dee244fd4..37c354b923 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -1665,18 +1665,24 @@ gpg_decrypt(CamelCipherContext *context, CamelMimePart *ipart, CamelMimePart *op struct _GpgCtx *gpg; CamelCipherValidity *valid = NULL; CamelStream *ostream, *istream; - + CamelDataWrapper *content; + CamelMimePart *encrypted; + CamelContentType *ct; + const char *protocol; + CamelMultipart *mp; + + mp = (CamelMultipart *) camel_medium_get_content_object ((CamelMedium *) ipart); + if (!(encrypted = camel_multipart_get_part (mp, CAMEL_MULTIPART_ENCRYPTED_CONTENT))) { + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to decrypt MIME part: protocol error")); + return NULL; + } + + content = camel_medium_get_content_object ((CamelMedium *) encrypted); + istream = camel_stream_mem_new(); - camel_data_wrapper_write_to_stream(camel_medium_get_content_object((CamelMedium *)ipart), istream); + camel_data_wrapper_decode_to_stream (content, istream); camel_stream_reset(istream); - - /* TODO: de-canonicalise end of lines? */ - /*stream = camel_stream_mem_new (); - filtered_stream = (CamelStream *) camel_stream_filter_new_with_stream (stream); - crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE, - CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); - camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered_stream), crlf_filter); - camel_object_unref (crlf_filter);*/ + ostream = camel_stream_mem_new(); camel_stream_mem_set_secure((CamelStreamMem *)ostream); -- cgit