Fix for bug 141730 (second try, with #ifdef this time). When forwarding inline or replying to an encrypted message, we need to decrypt the message body. R=kaie, SR=bienvenu,sspitzer

This commit is contained in:
ducarroz%netscape.com 2002-08-07 06:27:43 +00:00
parent 2d31535efd
commit 155328949b
2 changed files with 27 additions and 16 deletions

View file

@ -2092,14 +2092,12 @@ mime_bridge_create_draft_stream(
if (! (mdd->options->prefs && NS_SUCCEEDED(rv))) if (! (mdd->options->prefs && NS_SUCCEEDED(rv)))
goto FAIL; goto FAIL;
#ifdef FO_MAIL_MESSAGE_TO
/* If we're attaching a message (for forwarding) then we must eradicate all /* If we're attaching a message (for forwarding) then we must eradicate all
traces of xlateion from it, since forwarding someone else a message traces of xlateion from it, since forwarding someone else a message
that wasn't xlated for them doesn't work. We have to dexlate it that wasn't xlated for them doesn't work. We have to dexlate it
before sending it. before sending it.
*/ */
// RICHIE mdd->options->dexlate_p = PR_TRUE; mdd->options->decrypt_p = PR_TRUE;
#endif /* FO_MAIL_MESSAGE_TO */
obj = mime_new ( (MimeObjectClass *) &mimeMessageClass, (MimeHeaders *) NULL, MESSAGE_RFC822 ); obj = mime_new ( (MimeObjectClass *) &mimeMessageClass, (MimeHeaders *) NULL, MESSAGE_RFC822 );
if ( !obj ) if ( !obj )

View file

@ -52,6 +52,7 @@
#include "nsEscape.h" #include "nsEscape.h"
#include "nsString.h" #include "nsString.h"
#include "mimetext.h" #include "mimetext.h"
#include "mimecryp.h"
#define MIME_SUPERCLASS mimeContainerClass #define MIME_SUPERCLASS mimeContainerClass
MimeDefClass(MimeMessage, MimeMessageClass, mimeMessageClass, MimeDefClass(MimeMessage, MimeMessageClass, mimeMessageClass,
@ -294,10 +295,11 @@ MimeMessage_close_headers (MimeObject *obj)
(obj->options->decompose_file_p || obj->options->caller_need_root_headers) && (obj->options->decompose_file_p || obj->options->caller_need_root_headers) &&
obj->options->decompose_headers_info_fn) obj->options->decompose_headers_info_fn)
{ {
#ifdef MOZ_SECURITY #ifdef ENABLE_SMIME
HG09091 if (obj->options->decrypt_p && !mime_crypto_object_p (msg->hdrs, PR_FALSE))
#endif /* MOZ_SECURITY */ obj->options->decrypt_p = PR_FALSE;
if (!obj->options->caller_need_root_headers || (obj == obj->options->state->root)) #endif /* ENABLE_SMIME */
if (!obj->options->caller_need_root_headers || (obj == obj->options->state->root))
status = obj->options->decompose_headers_info_fn ( status = obj->options->decompose_headers_info_fn (
obj->options->stream_closure, obj->options->stream_closure,
msg->hdrs ); msg->hdrs );
@ -385,9 +387,24 @@ HG09091
PR_FREEIF(mv); /* done with this now. */ PR_FREEIF(mv); /* done with this now. */
} }
#ifdef MOZ_SECURITY #ifdef ENABLE_SMIME
HG67023 /* If this message has a body which is encrypted and we're going to
#endif /* MOZ_SECURITY */ decrypt it (whithout converting it to HTML, since decrypt_p and
write_html_p are never true at the same time)
*/
if (obj->output_p &&
obj->options &&
obj->options->decrypt_p &&
!mime_crypto_object_p (msg->hdrs, PR_FALSE))
{
/* The body of this message is not an encrypted object, so we need
to turn off the decrypt_p flag (to prevent us from s#$%ing the
body of the internal object up into one.) In this case,
our output will end up being identical to our input.
*/
obj->options->decrypt_p = PR_FALSE;
}
#endif /* ENABLE_SMIME */
/* Emit the HTML for this message's headers. Do this before /* Emit the HTML for this message's headers. Do this before
creating the object representing the body. creating the object representing the body.
@ -555,9 +572,7 @@ MimeMessage_parse_eof (MimeObject *obj, PRBool abort_p)
obj->options->decompose_file_p && obj->options->decompose_file_p &&
obj->options->done_parsing_outer_headers && obj->options->done_parsing_outer_headers &&
! obj->options->is_multipart_msg && ! obj->options->is_multipart_msg &&
#ifdef MOZ_SECURITY ! mime_typep(obj, (MimeObjectClass*) &mimeEncryptedClass) &&
HG00234
#endif /* MOZ_SECURITY */
obj->options->decompose_file_close_fn ) { obj->options->decompose_file_close_fn ) {
status = obj->options->decompose_file_close_fn ( status = obj->options->decompose_file_close_fn (
obj->options->stream_closure ); obj->options->stream_closure );
@ -593,9 +608,7 @@ MimeMessage_add_child (MimeObject *parent, MimeObject *child)
if ( parent->options && if ( parent->options &&
parent->options->decompose_file_p && parent->options->decompose_file_p &&
! parent->options->is_multipart_msg && ! parent->options->is_multipart_msg &&
#ifdef MOZ_SECURITY ! mime_typep(child, (MimeObjectClass*) &mimeEncryptedClass) &&
HG00234
#endif /* MOZ_SECURITY */
parent->options->decompose_file_init_fn ) { parent->options->decompose_file_init_fn ) {
int status = 0; int status = 0;
status = parent->options->decompose_file_init_fn ( status = parent->options->decompose_file_init_fn (