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 /camel/camel-mime-part.c | |
parent | 3a839acf2ae5f2d81d0390435204d227f2d0fe64 (diff) | |
download | gsoc2013-evolution-3de9db5ae79348a641351f6141b282ce5e9b50a9.tar.gz 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
Diffstat (limited to 'camel/camel-mime-part.c')
-rw-r--r-- | camel/camel-mime-part.c | 32 |
1 files changed, 20 insertions, 12 deletions
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); |