aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-01-09 10:06:03 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-01-09 10:06:03 +0800
commitcee49f028644048a129fefd513a396a145bb0a90 (patch)
treecc274529619f7a81a1a3e857854f80c9a7d46653 /mail
parentd26d8fe8ec5602bd5df2f66f6e07420cbbd5f441 (diff)
downloadgsoc2013-evolution-cee49f028644048a129fefd513a396a145bb0a90.tar.gz
gsoc2013-evolution-cee49f028644048a129fefd513a396a145bb0a90.tar.zst
gsoc2013-evolution-cee49f028644048a129fefd513a396a145bb0a90.zip
keep the windows charset filter around until we're done since if we set it
2004-01-09 Not Zed <NotZed@Ximian.com> * em-format.c (em_format_format_text): keep the windows charset filter around until we're done since if we set it up we reference its memory. Causes warnings and breaks message display. ** See bug #52637. * em-inline-filter.c (em_inline_filter_new): added a content-type paramter for the base content type. (em_inline_filter_finalize): free base content type. (emif_types[]): Added 'plain' parameter, indicates type needs plain parameters set on content type. (emif_add_part): inherit the full base type if it is set, for plain parts. * em-format-html.c (efh_text_plain): pass the part's content-type to the inline filter. svn path=/trunk/; revision=24121
Diffstat (limited to 'mail')
-rw-r--r--mail/em-format-html.c2
-rw-r--r--mail/em-format.c6
-rw-r--r--mail/em-inline-filter.c21
-rw-r--r--mail/em-inline-filter.h4
4 files changed, 25 insertions, 8 deletions
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index cf1ad35a52..47d23c9146 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -698,7 +698,7 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
null = camel_stream_null_new();
filtered_stream = camel_stream_filter_new_with_stream(null);
camel_object_unref(null);
- inline_filter = em_inline_filter_new(camel_mime_part_get_encoding(part));
+ inline_filter = em_inline_filter_new(camel_mime_part_get_encoding(part), ((CamelDataWrapper *)part)->mime_type);
camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)inline_filter);
camel_data_wrapper_write_to_stream(camel_medium_get_content_object((CamelMedium *)part), (CamelStream *)filtered_stream);
camel_stream_close((CamelStream *)filtered_stream);
diff --git a/mail/em-format.c b/mail/em-format.c
index 6d16e48df0..fef764f6ba 100644
--- a/mail/em-format.c
+++ b/mail/em-format.c
@@ -829,13 +829,13 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
CamelStreamFilter *filter_stream;
CamelMimeFilterCharset *filter;
const char *charset = NULL;
+ CamelMimeFilterWindows *windows = NULL;
if (emf->charset) {
charset = emf->charset;
} else if (dw->mime_type
&& (charset = camel_content_type_param (dw->mime_type, "charset"))
&& g_ascii_strncasecmp(charset, "iso-8859-", 9) == 0) {
- CamelMimeFilterWindows *windows;
CamelStream *null;
/* Since a few Windows mailers like to claim they sent
@@ -855,7 +855,6 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
camel_object_unref(filter_stream);
charset = camel_mime_filter_windows_real_charset (windows);
- camel_object_unref(windows);
} else if (charset == NULL) {
charset = emf->default_charset;
}
@@ -870,6 +869,9 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
camel_data_wrapper_decode_to_stream(dw, (CamelStream *)filter_stream);
camel_stream_flush((CamelStream *)filter_stream);
camel_object_unref(filter_stream);
+
+ if (windows)
+ camel_object_unref(windows);
}
/**
diff --git a/mail/em-inline-filter.c b/mail/em-inline-filter.c
index 3a38771efc..fc3752fef5 100644
--- a/mail/em-inline-filter.c
+++ b/mail/em-inline-filter.c
@@ -86,6 +86,9 @@ em_inline_filter_finalize (CamelObject *object)
{
EMInlineFilter *emif = (EMInlineFilter *)object;
+ if (emif->base_type)
+ camel_content_type_unref(emif->base_type);
+
emif_reset((CamelMimeFilter *)emif);
g_byte_array_free(emif->data, TRUE);
g_free(emif->filename);
@@ -101,12 +104,13 @@ enum {
const struct {
const char *name;
CamelTransferEncoding type;
+ int plain:1;
} emif_types[] = {
- { "text/plain", CAMEL_TRANSFER_ENCODING_DEFAULT, },
+ { "text/plain", CAMEL_TRANSFER_ENCODING_DEFAULT, 1, },
{ "application/octet-stream", CAMEL_TRANSFER_ENCODING_UUENCODE, },
{ "application/mac-binhex40", CAMEL_TRANSFER_ENCODING_7BIT, },
{ "application/postscript", CAMEL_TRANSFER_ENCODING_7BIT, },
- { "text/plain", CAMEL_TRANSFER_ENCODING_7BIT, },
+ { "text/plain", CAMEL_TRANSFER_ENCODING_7BIT, 1, },
};
static void
@@ -129,7 +133,10 @@ emif_add_part(EMInlineFilter *emif, const char *data, int len)
dw = camel_data_wrapper_new();
camel_data_wrapper_construct_from_stream(dw, mem);
camel_object_unref(mem);
- camel_data_wrapper_set_mime_type(dw, emif_types[emif->state].name);
+ if (emif_types[emif->state].plain && emif->base_type)
+ camel_data_wrapper_set_mime_type_field(dw, emif->base_type);
+ else
+ camel_data_wrapper_set_mime_type(dw, emif_types[emif->state].name);
dw->encoding = type;
part = camel_mime_part_new();
@@ -301,6 +308,8 @@ emif_reset(CamelMimeFilter *f)
* em_inline_filter_new:
* @base_encoding: The base transfer-encoding of the
* raw data being processed.
+ * @base_type: The base content-type of the raw data, should always be
+ * text/plain.
*
* Create a filter which will scan a (text) stream for
* embedded parts. You can then retrieve the contents
@@ -309,12 +318,16 @@ emif_reset(CamelMimeFilter *f)
* Return value:
**/
EMInlineFilter *
-em_inline_filter_new(CamelTransferEncoding base_encoding)
+em_inline_filter_new(CamelTransferEncoding base_encoding, CamelContentType *base_type)
{
EMInlineFilter *emif;
emif = (EMInlineFilter *)camel_object_new(em_inline_filter_get_type());
emif->base_encoding = base_encoding;
+ if (base_type) {
+ emif->base_type = base_type;
+ camel_content_type_ref(emif->base_type);
+ }
return emif;
}
diff --git a/mail/em-inline-filter.h b/mail/em-inline-filter.h
index 0afcdfa0b5..c2c82fee9b 100644
--- a/mail/em-inline-filter.h
+++ b/mail/em-inline-filter.h
@@ -42,6 +42,8 @@ typedef struct _EMInlineFilter {
int state;
CamelTransferEncoding base_encoding;
+ CamelContentType *base_type;
+
GByteArray *data;
char *filename;
GSList *parts;
@@ -52,7 +54,7 @@ typedef struct _EMInlineFilterClass {
} EMInlineFilterClass;
CamelType em_inline_filter_get_type(void);
-EMInlineFilter *em_inline_filter_new(CamelTransferEncoding base_encoding);
+EMInlineFilter *em_inline_filter_new(CamelTransferEncoding base_encoding, CamelContentType *type);
struct _CamelMultipart *em_inline_filter_get_multipart(EMInlineFilter *emif);
#ifdef __cplusplus