From 13c90a81d9b01ee7f19f3ce766c9504d0d02a9be Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 31 Aug 2000 02:24:49 +0000 Subject: Use the proper type checking function to check for text types. 2000-08-31 Not Zed * camel-mime-part.c (write_to_stream): Use the proper type checking function to check for text types. (write_to_stream): If we have a charset on a text type that isn't us-ascii or utf-8, then we need to reencode it, so add a filter to do that too. svn path=/trunk/; revision=5131 --- camel/camel-mime-part.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'camel/camel-mime-part.c') diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index f9519df5e4..ae33f5c8ce 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -517,11 +517,23 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) } if (filter) { filter_stream = camel_stream_filter_new_with_stream(stream); - if (!strcasecmp(mp->content_type->type, "text")) { + if (gmime_content_field_is_type(mp->content_type, "text", "*")) { CamelMimeFilter *crlf = camel_mime_filter_crlf_new(CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); + char *charset; + camel_stream_filter_add(filter_stream, crlf); camel_object_unref((CamelObject *)crlf); + + charset = gmime_content_field_get_parameter(mp->content_type, "charset"); + if (!(charset == NULL || !strcasecmp(charset, "us-ascii") || !strcasecmp(charset, "utf-8"))) { + CamelMimeFilter *charenc; + charenc = camel_mime_filter_charset_new("utf-8", charset); + camel_stream_filter_add(filter_stream, charenc); + /* well some idiot changed the _add function to do its own ref'ing for + no decent purpose whatsoever ... */ + camel_object_unref((CamelObject *)charenc); + } } camel_stream_filter_add(filter_stream, filter); camel_object_unref((CamelObject *)filter); -- cgit