aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2005-08-19 13:38:22 +0800
committerMichael Zucci <zucchi@src.gnome.org>2005-08-19 13:38:22 +0800
commit64c94ae9ce11ad1c94c0361244b468df8f758745 (patch)
tree2cce9155c795dac503cb160487432a158af48936
parentcb37c563afea6d1f7680fa845076992c749ee024 (diff)
downloadgsoc2013-evolution-64c94ae9ce11ad1c94c0361244b468df8f758745.tar
gsoc2013-evolution-64c94ae9ce11ad1c94c0361244b468df8f758745.tar.gz
gsoc2013-evolution-64c94ae9ce11ad1c94c0361244b468df8f758745.tar.bz2
gsoc2013-evolution-64c94ae9ce11ad1c94c0361244b468df8f758745.tar.lz
gsoc2013-evolution-64c94ae9ce11ad1c94c0361244b468df8f758745.tar.xz
gsoc2013-evolution-64c94ae9ce11ad1c94c0361244b468df8f758745.tar.zst
gsoc2013-evolution-64c94ae9ce11ad1c94c0361244b468df8f758745.zip
put the s/mime message back, awaiting string approval for a change
2005-08-19 Not Zed <NotZed@Ximian.com> * em-format.c (emf_multipart_encrypted): put the s/mime message back, awaiting string approval for a change otherwise. 2005-08-18 Not Zed <NotZed@Ximian.com> * em-format-html-display.c (efhd_message_add_bar): dont add attachment bar if it is disabled. (efhd_attachment_button): dont add attachments if there is no bar. * em-format.c (emf_inlinepgp_signed, emf_inlinepgp_encrypted): fix the error messages for consistency. We dont need to check content-type, since we only get called with the right one. (emf_multipart_encrypted): fix up wrong s/mime error. * em-format-html.c (efh_inlinepgp_signed) (efh_inlinepgp_encrypted): moved to em-format.c; otherwise this will break replying, etc. ** See #271894. * em-format.c (emf_multipart_encrypted): use the content object's content-type to check types. svn path=/trunk/; revision=30161
-rw-r--r--mail/ChangeLog25
-rw-r--r--mail/em-format-html-display.c68
-rw-r--r--mail/em-format-html-display.h1
-rw-r--r--mail/em-format-html.c114
-rw-r--r--mail/em-format.c109
5 files changed, 170 insertions, 147 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 3e54b80d59..3860b802c4 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,28 @@
+2005-08-19 Not Zed <NotZed@Ximian.com>
+
+ * em-format.c (emf_multipart_encrypted): put the s/mime message
+ back, awaiting string approval for a change otherwise.
+
+2005-08-18 Not Zed <NotZed@Ximian.com>
+
+ * em-format-html-display.c (efhd_message_add_bar): dont add
+ attachment bar if it is disabled.
+ (efhd_attachment_button): dont add attachments if there is no bar.
+
+ * em-format.c (emf_inlinepgp_signed, emf_inlinepgp_encrypted): fix
+ the error messages for consistency. We dont need to check
+ content-type, since we only get called with the right one.
+ (emf_multipart_encrypted): fix up wrong s/mime error.
+
+ * em-format-html.c (efh_inlinepgp_signed)
+ (efh_inlinepgp_encrypted): moved to em-format.c; otherwise this
+ will break replying, etc.
+
+ ** See #271894.
+
+ * em-format.c (emf_multipart_encrypted): use the content object's
+ content-type to check types.
+
2005-08-16 Not Zed <NotZed@Ximian.com>
** See #312668.
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 973f771ca0..c9340f3aa2 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -276,6 +276,8 @@ efhd_init(GObject *o)
efh->text_html_flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES;
#undef efh
+ efhd->nobar = getenv("EVOLUTION_NO_BAR") != NULL;
+
efhd->priv->show_bar = FALSE;
efhd->priv->files = NULL;
}
@@ -1431,45 +1433,47 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
g_assert(info != NULL);
g_assert(info->forward == NULL);
- file = camel_mime_part_get_filename(info->puri.part);
+ if (efhd->priv->attachment_bar) {
+ file = camel_mime_part_get_filename(info->puri.part);
- new = e_attachment_new_from_mime_part (info->puri.part);
+ new = e_attachment_new_from_mime_part (info->puri.part);
- if (!file) {
- file = "attachment.dat";
- new->file_name = g_strdup(file);
- }
+ if (!file) {
+ file = "attachment.dat";
+ new->file_name = g_strdup(file);
+ }
- tmp = g_hash_table_lookup (efhd->priv->files, file);
- if (tmp) {
- guint count = GPOINTER_TO_UINT(tmp);
- char *ext;
- char *tmp_file = g_strdup (file);
+ tmp = g_hash_table_lookup (efhd->priv->files, file);
+ if (tmp) {
+ guint count = GPOINTER_TO_UINT(tmp);
+ char *ext;
+ char *tmp_file = g_strdup (file);
- if ((ext = strrchr(tmp_file, '.'))) {
- ext[0] = 0;
- new_file = g_strdup_printf("%s(%d).%s", tmp_file, count++, ext+1);
+ if ((ext = strrchr(tmp_file, '.'))) {
+ ext[0] = 0;
+ new_file = g_strdup_printf("%s(%d).%s", tmp_file, count++, ext+1);
+ } else {
+ new_file = g_strdup_printf("%s(%d)", tmp_file, count++);
+ }
+
+ g_free (tmp_file);
+ g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(count));
+ g_free (new->file_name);
+ new->file_name = new_file;
} else {
- new_file = g_strdup_printf("%s(%d)", tmp_file, count++);
+ g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(1));
}
- g_free (tmp_file);
- g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(count));
- g_free (new->file_name);
- new->file_name = new_file;
- } else {
- g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(1));
- }
-
- /* Store the status of encryption / signature on the attachment for emblem display
- * FIXME: May not work well always
- */
- new->sign = info->sign;
- new->encrypt = info->encrypt;
+ /* Store the status of encryption / signature on the attachment for emblem display
+ * FIXME: May not work well always
+ */
+ new->sign = info->sign;
+ new->encrypt = info->encrypt;
- /* Add the attachment to the bar.*/
- e_attachment_bar_add_attachment (E_ATTACHMENT_BAR(efhd->priv->attachment_bar), new);
- efhd_attachment_bar_refresh (efhd);
+ /* Add the attachment to the bar.*/
+ e_attachment_bar_add_attachment(E_ATTACHMENT_BAR(efhd->priv->attachment_bar), new);
+ efhd_attachment_bar_refresh(efhd);
+ }
mainbox = gtk_hbox_new(FALSE, 0);
@@ -1984,7 +1988,7 @@ efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, co
EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf;
const char *classid = "attachment-bar";
- if (efhd->priv->files)
+ if (efhd->nobar || efhd->priv->files)
return;
efhd->priv->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
diff --git a/mail/em-format-html-display.h b/mail/em-format-html-display.h
index 6457f8d637..df5ebff9d4 100644
--- a/mail/em-format-html-display.h
+++ b/mail/em-format-html-display.h
@@ -22,6 +22,7 @@ struct _EMFormatHTMLDisplay {
unsigned int animate:1;
unsigned int caret_mode:1;
+ unsigned int nobar:1;
};
#define EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY (0)
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 5e9b2626a9..7f06969297 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -48,7 +48,6 @@
#include <camel/camel-mime-filter.h>
#include <camel/camel-mime-filter-tohtml.h>
#include <camel/camel-mime-filter-enriched.h>
-#include <camel/camel-mime-filter-pgp.h>
#include <camel/camel-mime-filter-basic.h>
#include <camel/camel-gpg-context.h>
#include <camel/camel-cipher-context.h>
@@ -660,117 +659,6 @@ efh_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, Camel
camel_stream_printf(stream, "</td></tr></table>");
}
}
-
-static void
-efh_inlinepgp_signed(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *ipart, EMFormatHandler *info)
-{
-
- CamelCipherContext *cipher;
- CamelCipherValidity *valid;
- CamelException *ex;
- CamelMimePart *opart=NULL;
- CamelContentType *type;
- CamelStreamFilter *filtered_stream;
- CamelStream *ostream;
- CamelDataWrapper *dw;
- CamelMimeFilterPgp *pgp_filter;
-
- /* Check we're passed valid input */
- type = camel_mime_part_get_content_type(ipart);
- if (!camel_content_type_is(type, "application", "x-inlinepgp-signed")) {
- em_format_format_error((EMFormat *)efh, stream,
- "Invalid mime type passed to inline PGP format");
- return;
- }
-
- ex = camel_exception_new();
- cipher = camel_gpg_context_new (((EMFormat *)efh)->session);
- /* Verify the signature of the message */
- valid = camel_cipher_verify(cipher, ipart, ex);
- if (!valid) {
- /* Display an error */
- em_format_format_error((EMFormat *)efh, stream, ex->desc ? ex->desc :
- _("Unknown error verifying signed messaage"));
- camel_exception_free(ex);
- camel_object_unref(cipher);
- return;
- }
-
- /* Setup output stream */
- ostream = camel_stream_mem_new();
- filtered_stream = camel_stream_filter_new_with_stream(ostream);
-
- /* Add PGP header / footer filter */
- pgp_filter = (CamelMimeFilterPgp *)camel_mime_filter_pgp_new();
- camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)pgp_filter);
- camel_object_unref(pgp_filter);
-
- /* Pass through the filters that have been setup */
- dw = camel_medium_get_content_object((CamelMedium *)ipart);
- camel_data_wrapper_decode_to_stream(dw, (CamelStream *)filtered_stream);
- camel_stream_flush((CamelStream *)filtered_stream);
- camel_object_unref(filtered_stream);
-
- /* Extract new part and display it as text/plain */
- dw = camel_data_wrapper_new();
- camel_data_wrapper_construct_from_stream(dw, ostream);
- camel_data_wrapper_set_mime_type(dw, "text/plain");
- opart = camel_mime_part_new();
- camel_medium_set_content_object((CamelMedium *)opart, dw);
- camel_mime_part_set_content_type(opart, "text/plain");
-
- /* Pass it off to the real formatter */
- em_format_format_secure((EMFormat *)efh, stream, opart, valid);
-
- /* Clean Up */
- camel_object_unref(dw);
- camel_object_unref(opart);
- camel_object_unref(ostream);
- camel_object_unref(cipher);
- camel_exception_free(ex);
-}
-
-static void
-efh_inlinepgp_encrypted(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *ipart, EMFormatHandler *info)
-{
- CamelCipherContext *cipher;
- CamelCipherValidity *valid;
- CamelException *ex;
- CamelMimePart *opart;
- CamelContentType *type;
-
- /* Check we're passed valid input */
- type = camel_mime_part_get_content_type(ipart);
- if (!camel_content_type_is(type, "application", "x-inlinepgp-encrypted")) {
- em_format_format_error((EMFormat *)efh, stream,
- "Invalid mime type passed to inline PGP format encrypted");
- return;
- }
-
- cipher = camel_gpg_context_new (((EMFormat *)efh)->session);
- ex = camel_exception_new();
- opart = camel_mime_part_new();
- /* Decrypt the message */
- valid = camel_cipher_decrypt (cipher, ipart, opart, ex);
- if (!valid) {
- /* Display an error */
- em_format_format_error((EMFormat *)efh, stream, ex->desc ? ex->desc :
- _("Unknown error decrypting messaage"));
- camel_exception_free(ex);
- camel_object_unref(cipher);
- camel_object_unref(opart);
- return;
- }
-
- /* Pass it off to the real formatter */
- em_format_format_secure((EMFormat *)efh, stream, opart, valid);
-
- /* Clean Up */
- camel_object_unref(opart);
- camel_object_unref (cipher);
- camel_exception_free (ex);
-}
-
static void
efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
@@ -1227,8 +1115,6 @@ static EMFormatHandler type_builtin_table[] = {
{ "message/external-body", (EMFormatFunc)efh_message_external },
{ "message/delivery-status", (EMFormatFunc)efh_message_deliverystatus },
{ "multipart/related", (EMFormatFunc)efh_multipart_related },
- { "application/x-inlinepgp-signed", (EMFormatFunc)efh_inlinepgp_signed },
- { "application/x-inlinepgp-encrypted", (EMFormatFunc)efh_inlinepgp_encrypted },
/* This is where one adds those busted, non-registered types,
that some idiot mailer writers out there decide to pull out
diff --git a/mail/em-format.c b/mail/em-format.c
index 61bd9551b6..965eea48d5 100644
--- a/mail/em-format.c
+++ b/mail/em-format.c
@@ -49,6 +49,7 @@
#include <camel/camel-stream-null.h>
#include <camel/camel-mime-filter-charset.h>
#include <camel/camel-mime-filter-windows.h>
+#include <camel/camel-mime-filter-pgp.h>
#include "em-format.h"
#include "em-utils.h"
@@ -1254,6 +1255,7 @@ emf_multipart_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *part,
const char *protocol;
CamelMimePart *opart;
CamelCipherValidity *valid;
+ CamelMultipartEncrypted *mpe;
struct _EMFormatCache *emfc;
/* should this perhaps run off a key of ".secured" ? */
@@ -1263,8 +1265,15 @@ emf_multipart_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *part,
return;
}
+ mpe = (CamelMultipartEncrypted*)camel_medium_get_content_object((CamelMedium *)part);
+ if (!CAMEL_IS_MULTIPART_ENCRYPTED(mpe)) {
+ em_format_format_error(emf, stream, _("Could not parse MIME message. Displaying as source."));
+ em_format_format_source(emf, stream, part);
+ return;
+ }
+
/* Currently we only handle RFC2015-style PGP encryption. */
- protocol = camel_content_type_param (((CamelDataWrapper *) part)->mime_type, "protocol");
+ protocol = camel_content_type_param(((CamelDataWrapper *)mpe)->mime_type, "protocol");
if (!protocol || g_ascii_strcasecmp (protocol, "application/pgp-encrypted") != 0) {
em_format_format_error(emf, stream, _("Unsupported encryption type for multipart/encrypted"));
em_format_part_as(emf, stream, part, "multipart/mixed");
@@ -1488,6 +1497,101 @@ emf_message_deliverystatus(EMFormat *emf, CamelStream *stream, CamelMimePart *pa
em_format_format_text(emf, stream, camel_medium_get_content_object((CamelMedium *)part));
}
+static void
+emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, EMFormatHandler *info)
+{
+ CamelCipherContext *cipher;
+ CamelCipherValidity *valid;
+ CamelException *ex;
+ CamelMimePart *opart=NULL;
+ CamelStreamFilter *filtered_stream;
+ CamelStream *ostream;
+ CamelDataWrapper *dw;
+ CamelMimeFilterPgp *pgp_filter;
+
+ ex = camel_exception_new();
+ cipher = camel_gpg_context_new(emf->session);
+ /* Verify the signature of the message */
+ valid = camel_cipher_verify(cipher, ipart, ex);
+ if (!valid) {
+ em_format_format_error(emf, stream, ex->desc?_("Error verifying signature"):_("Unknown error verifying signature"));
+ if (ex->desc)
+ em_format_format_error(emf, stream, ex->desc);
+ em_format_format_source(emf, stream, ipart);
+ /* I think this will loop: em_format_part_as(emf, stream, part, "text/plain"); */
+ camel_exception_free(ex);
+ camel_object_unref(cipher);
+ return;
+ }
+
+ /* Setup output stream */
+ ostream = camel_stream_mem_new();
+ filtered_stream = camel_stream_filter_new_with_stream(ostream);
+
+ /* Add PGP header / footer filter */
+ pgp_filter = (CamelMimeFilterPgp *)camel_mime_filter_pgp_new();
+ camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)pgp_filter);
+ camel_object_unref(pgp_filter);
+
+ /* Pass through the filters that have been setup */
+ dw = camel_medium_get_content_object((CamelMedium *)ipart);
+ camel_data_wrapper_decode_to_stream(dw, (CamelStream *)filtered_stream);
+ camel_stream_flush((CamelStream *)filtered_stream);
+ camel_object_unref(filtered_stream);
+
+ /* Extract new part and display it as text/plain */
+ dw = camel_data_wrapper_new();
+ camel_data_wrapper_construct_from_stream(dw, ostream);
+ camel_data_wrapper_set_mime_type(dw, "text/plain");
+ opart = camel_mime_part_new();
+ camel_medium_set_content_object((CamelMedium *)opart, dw);
+ camel_mime_part_set_content_type(opart, "text/plain");
+
+ /* Pass it off to the real formatter */
+ em_format_format_secure(emf, stream, opart, valid);
+
+ /* Clean Up */
+ camel_object_unref(dw);
+ camel_object_unref(opart);
+ camel_object_unref(ostream);
+ camel_object_unref(cipher);
+ camel_exception_free(ex);
+}
+
+static void
+emf_inlinepgp_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, EMFormatHandler *info)
+{
+ CamelCipherContext *cipher;
+ CamelCipherValidity *valid;
+ CamelException *ex;
+ CamelMimePart *opart;
+
+ cipher = camel_gpg_context_new(emf->session);
+ ex = camel_exception_new();
+ opart = camel_mime_part_new();
+ /* Decrypt the message */
+ valid = camel_cipher_decrypt (cipher, ipart, opart, ex);
+ if (!valid) {
+ em_format_format_error(emf, stream, ex->desc?("Could not parse S/MIME message"):_("Could not parse S/MIME message: Unknown error"));
+ if (ex->desc)
+ em_format_format_error(emf, stream, ex->desc);
+ em_format_format_source(emf, stream, ipart);
+ /* I think this will loop: em_format_part_as(emf, stream, part, "text/plain"); */
+ camel_exception_free(ex);
+ camel_object_unref(cipher);
+ camel_object_unref(opart);
+ return;
+ }
+
+ /* Pass it off to the real formatter */
+ em_format_format_secure(emf, stream, opart, valid);
+
+ /* Clean Up */
+ camel_object_unref(opart);
+ camel_object_unref (cipher);
+ camel_exception_free (ex);
+}
+
static EMFormatHandler type_builtin_table[] = {
#ifdef ENABLE_SMIME
{ "application/x-pkcs7-mime", (EMFormatFunc)emf_application_xpkcs7mime, EM_FORMAT_HANDLER_INLINE_DISPOSITION },
@@ -1509,6 +1613,9 @@ static EMFormatHandler type_builtin_table[] = {
{ "application/pkcs7-mime", (EMFormatFunc)emf_application_xpkcs7mime, EM_FORMAT_HANDLER_INLINE_DISPOSITION },
#endif
+ /* internal types */
+ { "application/x-inlinepgp-signed", (EMFormatFunc)emf_inlinepgp_signed },
+ { "application/x-inlinepgp-encrypted", (EMFormatFunc)emf_inlinepgp_encrypted },
};
static void