aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-part-utils.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-03-22 05:54:59 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-03-22 05:54:59 +0800
commit2e5eb47695ee59d15af41686a9f091cfe2407ed0 (patch)
treee2e5b339005bafa76b9661cb40e31903c6fca25c /camel/camel-mime-part-utils.c
parentd7a4a66632cac7424bc158ace966b9ac950f4337 (diff)
downloadgsoc2013-evolution-2e5eb47695ee59d15af41686a9f091cfe2407ed0.tar
gsoc2013-evolution-2e5eb47695ee59d15af41686a9f091cfe2407ed0.tar.gz
gsoc2013-evolution-2e5eb47695ee59d15af41686a9f091cfe2407ed0.tar.bz2
gsoc2013-evolution-2e5eb47695ee59d15af41686a9f091cfe2407ed0.tar.lz
gsoc2013-evolution-2e5eb47695ee59d15af41686a9f091cfe2407ed0.tar.xz
gsoc2013-evolution-2e5eb47695ee59d15af41686a9f091cfe2407ed0.tar.zst
gsoc2013-evolution-2e5eb47695ee59d15af41686a9f091cfe2407ed0.zip
Camel part of the fix for Lewing's bug #39204. Second half of the patch
2003-03-21 Jeffrey Stedfast <fejj@ximian.com> Camel part of the fix for Lewing's bug #39204. Second half of the patch should also fix it so that text/plain parts that are detected as being text/html are rendered as html (not that I agree with this mind you, but corporate customers want this "feature"). * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): If the part is text/html and doesn't have a charset and we are able to find a charset in the meta tags of the html content, set the charset param on the content-type. (camel_mime_part_construct_content_from_parser): After setting the content object on the mime part, re-set the content-type of the content object back to the one from the parser (as it may contain changes from the original - see changes made to the ct in simple_data_wrapper_construct_from_parser for details). svn path=/trunk/; revision=20463
Diffstat (limited to 'camel/camel-mime-part-utils.c')
-rw-r--r--camel/camel-mime-part-utils.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 32f4397d64..d71108afa5 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -352,8 +352,10 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser
}
/* Possible Lame Mailer Alert... check the META tags for a charset */
- if (!charset && header_content_type_is (ct, "text", "html"))
- charset = check_html_charset (buffer->data, buffer->len);
+ if (!charset && header_content_type_is (ct, "text", "html")) {
+ if ((charset = check_html_charset (buffer->data, buffer->len)))
+ header_content_type_set_param (ct, "charset", charset);
+ }
/* if we need to do charset conversion, see if we can/it works/etc */
if (charset && !(strcasecmp (charset, "us-ascii") == 0
@@ -416,12 +418,15 @@ void
camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParser *mp)
{
CamelDataWrapper *content = NULL;
+ CamelContentType *ct;
+
+ ct = camel_mime_parser_content_type (mp);
switch (camel_mime_parser_state (mp)) {
case HSCAN_HEADER:
d(printf("Creating body part\n"));
/* multipart/signed is some fucked up type that we must treat as binary data, fun huh, idiots. */
- if (header_content_type_is (camel_mime_parser_content_type (mp), "multipart", "signed")) {
+ if (header_content_type_is (ct, "multipart", "signed")) {
content = (CamelDataWrapper *) camel_multipart_signed_new ();
camel_multipart_construct_from_parser ((CamelMultipart *) content, mp);
} else {
@@ -436,9 +441,9 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse
break;
case HSCAN_MULTIPART:
d(printf("Creating multi-part\n"));
- if (header_content_type_is (camel_mime_parser_content_type (mp), "multipart", "encrypted"))
+ if (header_content_type_is (ct, "multipart", "encrypted"))
content = (CamelDataWrapper *) camel_multipart_encrypted_new ();
- else if (header_content_type_is (camel_mime_parser_content_type (mp), "multipart", "signed"))
+ else if (header_content_type_is (ct, "multipart", "signed"))
content = (CamelDataWrapper *) camel_multipart_signed_new ();
else
content = (CamelDataWrapper *) camel_multipart_new ();
@@ -451,9 +456,17 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse
}
if (content) {
/* would you believe you have to set this BEFORE you set the content object??? oh my god !!!! */
- camel_data_wrapper_set_mime_type_field (content,
- camel_mime_part_get_content_type ((CamelMimePart *)dw));
+ camel_data_wrapper_set_mime_type_field (content, camel_mime_part_get_content_type (dw));
camel_medium_set_content_object ((CamelMedium *)dw, content);
- camel_object_unref ((CamelObject *)content);
+
+ /* Note: we don't set ct as the content-object's mime-type above because
+ * camel_medium_set_content_object() may re-write the Content-Type header
+ * (see CamelMimePart::set_content_object) if we did that (which is a Bad Thing).
+ * However, if we set it *afterward*, we can still use any special auto-detections
+ * that we found in simple_data_wrapper_construct_from_parser(). This is important
+ * later when we go to render the MIME parts in mail-format.c */
+ camel_data_wrapper_set_mime_type_field (content, ct);
+
+ camel_object_unref (content);
}
}