aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-12-17 07:45:41 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-12-17 07:45:41 +0800
commit7d7d2b7729c4dc29b8b88062c0b023b1f85dc8a5 (patch)
tree35ea91ec453f131bab9bbb1da2610173bcaae5bb /camel
parentb6a3b64021ca544c738b9c68ea171712f7785acd (diff)
downloadgsoc2013-evolution-7d7d2b7729c4dc29b8b88062c0b023b1f85dc8a5.tar
gsoc2013-evolution-7d7d2b7729c4dc29b8b88062c0b023b1f85dc8a5.tar.gz
gsoc2013-evolution-7d7d2b7729c4dc29b8b88062c0b023b1f85dc8a5.tar.bz2
gsoc2013-evolution-7d7d2b7729c4dc29b8b88062c0b023b1f85dc8a5.tar.lz
gsoc2013-evolution-7d7d2b7729c4dc29b8b88062c0b023b1f85dc8a5.tar.xz
gsoc2013-evolution-7d7d2b7729c4dc29b8b88062c0b023b1f85dc8a5.tar.zst
gsoc2013-evolution-7d7d2b7729c4dc29b8b88062c0b023b1f85dc8a5.zip
Detect text/html parts that were marked as text/plain and re-tag them as
2002-12-16 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): Detect text/html parts that were marked as text/plain and re-tag them as text/html parts. Note: currently just checks if the first non-lwsp char is a '<' - but we might need to be smarter about this? *sigh* Stupid Windows mailers. svn path=/trunk/; revision=19143
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog7
-rw-r--r--camel/camel-mime-part-utils.c46
2 files changed, 39 insertions, 14 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 64768a5425..a811acd7cc 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,12 @@
2002-12-16 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-mime-part-utils.c
+ (simple_data_wrapper_construct_from_parser): Detect text/html
+ parts that were marked as text/plain and re-tag them as text/html
+ parts. Note: currently just checks if the first non-lwsp char is a
+ '<' - but we might need to be smarter about this? *sigh* Stupid
+ Windows mailers.
+
* camel-mime-filter-tohtml.c (camel_text_to_html): New convenience
function to replace calls to e_text_to_html() in the
mailer/composer etc.
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index c7ee07f070..c6fbd65404 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -231,8 +231,8 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser
int len, decid = -1, crlfid = -1;
struct _header_content_type *ct;
const char *charset = NULL;
- GByteArray *buffer;
char *encoding, *buf;
+ GByteArray *buffer;
CamelStream *mem;
d(printf ("simple_data_wrapper_construct_from_parser()\n"));
@@ -259,29 +259,47 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser
}
/* If we're doing text, we also need to do CRLF->LF and may have to convert it to UTF8 as well. */
- ct = camel_mime_parser_content_type(mp);
- if (header_content_type_is(ct, "text", "*")) {
- charset = header_content_type_param(ct, "charset");
- charset = e_iconv_charset_name(charset);
+ ct = camel_mime_parser_content_type (mp);
+ if (header_content_type_is (ct, "text", "*")) {
+ charset = header_content_type_param (ct, "charset");
+ charset = e_iconv_charset_name (charset);
if (fdec) {
- d(printf("Adding CRLF conversion filter\n"));
- fcrlf = (CamelMimeFilter *)camel_mime_filter_crlf_new(CAMEL_MIME_FILTER_CRLF_DECODE,
- CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
- crlfid = camel_mime_parser_filter_add(mp, fcrlf);
+ d(printf ("Adding CRLF conversion filter\n"));
+ fcrlf = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE,
+ CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ crlfid = camel_mime_parser_filter_add (mp, fcrlf);
}
}
/* read in the entire content */
- buffer = g_byte_array_new();
- while (camel_mime_parser_step(mp, &buf, &len) != HSCAN_BODY_END) {
+ buffer = g_byte_array_new ();
+ while (camel_mime_parser_step (mp, &buf, &len) != HSCAN_BODY_END) {
d(printf("appending o/p data: %d: %.*s\n", len, len, buf));
- g_byte_array_append(buffer, buf, len);
+ g_byte_array_append (buffer, buf, len);
}
-
+
+ /* check for broken Outlook/Web mailers that like to send html marked as text/plain */
+ if (header_content_type_is (ct, "text", "plain")) {
+ register const unsigned char *inptr;
+ const unsigned char *inend;
+
+ inptr = buffer->data;
+ inend = inptr + buffer->len;
+
+ while (inptr < inend && isspace ((int) *inptr))
+ inptr++;
+
+ if (inptr < inend && *inptr == '<') {
+ /* re-tag as text/html */
+ g_free (ct->subtype);
+ ct->subtype = g_strdup ("html");
+ }
+ }
+
/* 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);
+ charset = check_html_charset (buffer->data, buffer->len);
/* if we need to do charset conversion, see if we can/it works/etc */
if (charset && !(strcasecmp (charset, "us-ascii") == 0