aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-format.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-10-28 07:30:07 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-10-28 07:30:07 +0800
commit6cf3eed5909ede44c085e81d2a822455973f2fa9 (patch)
tree0c6883e9bdb229c4acc8c2496a96660f00227d29 /mail/mail-format.c
parentd109123edcdc7edc2d07298f23a7045bd14bf92a (diff)
downloadgsoc2013-evolution-6cf3eed5909ede44c085e81d2a822455973f2fa9.tar.gz
gsoc2013-evolution-6cf3eed5909ede44c085e81d2a822455973f2fa9.tar.zst
gsoc2013-evolution-6cf3eed5909ede44c085e81d2a822455973f2fa9.zip
Allow the user to shoot him/herself in the foot when overriding message
2001-10-27 Jeffrey Stedfast <fejj@ximian.com> * mail-format.c (mail_format_get_data_wrapper_text): Allow the user to shoot him/herself in the foot when overriding message charsets. Permanantly fixes bug #921. svn path=/trunk/; revision=14240
Diffstat (limited to 'mail/mail-format.c')
-rw-r--r--mail/mail-format.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 91343af07b..96d95698b9 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -1060,10 +1060,33 @@ mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_
filtered_stream = camel_stream_filter_new_with_stream (memstream);
camel_object_unref (CAMEL_OBJECT (memstream));
- if (wrapper->rawtext) {
+ if (wrapper->rawtext || (mail_display && mail_display->charset)) {
CamelMimeFilterCharset *filter;
const char *charset;
+ if (!wrapper->rawtext) {
+ /* data wrapper had been successfully converted to UTF-8 using the mime
+ part's charset, but the user thinks he knows best so we'll let him
+ shoot himself in the foot here... */
+ CamelContentType *content_type;
+
+ /* get the original charset of the mime part */
+ content_type = camel_data_wrapper_get_mime_type_field (wrapper);
+ charset = content_type ? header_content_type_param (content_type, "charset") : NULL;
+ if (!charset)
+ charset = mail_config_get_default_charset ();
+
+ /* since the content is already in UTF-8, we need to decode into the
+ original charset before we can convert back to UTF-8 using the charset
+ the user is overriding with... */
+ filter = camel_mime_filter_charset_new_convert ("utf-8", charset);
+ if (filter) {
+ camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (filter));
+ camel_object_unref (CAMEL_OBJECT (filter));
+ }
+ }
+
+ /* find out the charset the user wants to override to */
if (mail_display && mail_display->charset)
charset = mail_display->charset;
else