diff options
author | Michael Zucci <zucchi@src.gnome.org> | 2000-08-31 11:08:51 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-08-31 11:08:51 +0800 |
commit | 3de9db5ae79348a641351f6141b282ce5e9b50a9 (patch) | |
tree | 85243589a213d0391b08dfadd92d24af6a4ae495 | |
parent | 3a839acf2ae5f2d81d0390435204d227f2d0fe64 (diff) | |
download | gsoc2013-evolution-3de9db5ae79348a641351f6141b282ce5e9b50a9.tar gsoc2013-evolution-3de9db5ae79348a641351f6141b282ce5e9b50a9.tar.gz gsoc2013-evolution-3de9db5ae79348a641351f6141b282ce5e9b50a9.tar.bz2 gsoc2013-evolution-3de9db5ae79348a641351f6141b282ce5e9b50a9.tar.lz gsoc2013-evolution-3de9db5ae79348a641351f6141b282ce5e9b50a9.tar.xz gsoc2013-evolution-3de9db5ae79348a641351f6141b282ce5e9b50a9.tar.zst gsoc2013-evolution-3de9db5ae79348a641351f6141b282ce5e9b50a9.zip |
(write_to_stream): Rearrange the logic so it always does charset
conversion, and not just if we have a qp/base64 block.
svn path=/trunk/; revision=5134
-rw-r--r-- | camel/ChangeLog | 2 | ||||
-rw-r--r-- | camel/camel-mime-part.c | 32 |
2 files changed, 22 insertions, 12 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index f074a045cf..650948e8fc 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -7,6 +7,8 @@ filter to do that too. (write_to_stream): Fix some warnings/use the right constructor, oops. + (write_to_stream): Rearrange the logic so it always does charset + conversion, and not just if we have a qp/base64 block. * camel-mime-utils.c (append_latin1): New function - even though its broken, we'll assume mailers send latin1 headers instead of diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 20e26e110e..9dba5162a4 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -505,6 +505,8 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) #ifdef CAN_THIS_GO_ELSEWHERE CamelMimeFilter *filter = NULL; CamelStreamFilter *filter_stream = NULL; + CamelMimeFilter *charenc = NULL; + const char *charset; switch(mp->encoding) { case CAMEL_MIME_PART_ENCODING_BASE64: @@ -516,25 +518,31 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) default: break; } - if (filter) { + + if (gmime_content_field_is_type(mp->content_type, "text", "*")) { + charset = gmime_content_field_get_parameter(mp->content_type, "charset"); + if (!(charset == NULL || !strcasecmp(charset, "us-ascii") || !strcasecmp(charset, "utf-8"))) { + charenc = (CamelMimeFilter *)camel_mime_filter_charset_new_convert("utf-8", charset); + } + } + + if (filter || charenc) { filter_stream = camel_stream_filter_new_with_stream(stream); - if (gmime_content_field_is_type(mp->content_type, "text", "*")) { + + /* if we have a character encoder, add that always */ + if (charenc) { + camel_stream_filter_add(filter_stream, charenc); + camel_object_unref((CamelObject *)charenc); + } + + /* we only re-do crlf on encoded blocks */ + if (filter && 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); - const 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 = (CamelMimeFilter *)camel_mime_filter_charset_new_convert("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); |