aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-10-19 10:34:13 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-10-19 10:34:13 +0800
commitec619f7bfaf14ee913f565664459103507adb34f (patch)
treeeb32e8fe811b4ddf4215a5e471aedb66edc9cec5 /camel
parentdfd09f4f17bc75a3d8d745e850f00bbee919d820 (diff)
downloadgsoc2013-evolution-ec619f7bfaf14ee913f565664459103507adb34f.tar
gsoc2013-evolution-ec619f7bfaf14ee913f565664459103507adb34f.tar.gz
gsoc2013-evolution-ec619f7bfaf14ee913f565664459103507adb34f.tar.bz2
gsoc2013-evolution-ec619f7bfaf14ee913f565664459103507adb34f.tar.lz
gsoc2013-evolution-ec619f7bfaf14ee913f565664459103507adb34f.tar.xz
gsoc2013-evolution-ec619f7bfaf14ee913f565664459103507adb34f.tar.zst
gsoc2013-evolution-ec619f7bfaf14ee913f565664459103507adb34f.zip
If a charset isn't specified or claims to be utf-8, check the validity of
2001-10-18 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): If a charset isn't specified or claims to be utf-8, check the validity of the text and if it's invalid, set the rawtext bit to TRUE. If the charset is x-unknown or some other x- charset, always set the rawtext bit to TRUE. svn path=/trunk/; revision=13785
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/camel-mime-part-utils.c30
2 files changed, 37 insertions, 2 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 0ff46a9dcd..acd3428658 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,12 @@
+2001-10-18 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-mime-part-utils.c
+ (simple_data_wrapper_construct_from_parser): If a charset isn't
+ specified or claims to be utf-8, check the validity of the text
+ and if it's invalid, set the rawtext bit to TRUE. If the charset
+ is x-unknown or some other x- charset, always set the rawtext bit
+ to TRUE.
+
2001-10-18 <NotZed@Ximian.com>
* providers/(imap|local|pop3|sendmail|smtp)/Makefile.am: Added
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 597b1e9045..831559ee27 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -32,6 +32,7 @@
#include <errno.h>
#include <gal/util/e-iconv.h>
+#include <gal/unicode/gunicode.h>
#include "string-utils.h"
#include "camel-mime-part-utils.h"
@@ -153,6 +154,18 @@ static GByteArray *convert_buffer(GByteArray *in, const char *to, const char *fr
return out;
}
+static gboolean
+is_7bit (GByteArray *buffer)
+{
+ register int i;
+
+ for (i = 0; i < buffer->len; i++)
+ if (buffer->data[i] > 127)
+ return FALSE;
+
+ return TRUE;
+}
+
/* simple data wrapper */
static void
simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser *mp)
@@ -210,13 +223,13 @@ 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 we need to do charset conversion, see if we can/it works/etc */
if (charset && !(strcasecmp(charset, "us-ascii") == 0
|| strcasecmp(charset, "utf-8") == 0
|| strncasecmp(charset, "x-", 2) == 0)) {
GByteArray *out;
-
+
out = convert_buffer(buffer, "UTF-8", charset);
if (out) {
/* converted ok, use this data instead */
@@ -228,7 +241,20 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser
dw->rawtext = TRUE;
/* should we change the content-type header? */
}
+ } else {
+ if (charset == NULL) {
+ /* check that it's 7bit */
+ dw->rawtext = !is_7bit (buffer);
+ } else if (!strncasecmp (charset, "x-", 2)) {
+ /* we're not even going to bother trying to convert, so set the
+ rawtext bit to TRUE and let the mailer deal with it. */
+ dw->rawtext = TRUE;
+ } else if (!strcasecmp (charset, "utf-8")) {
+ /* check that it is valid utf8 */
+ dw->rawtext = !g_utf8_validate (buffer->data, buffer->len, NULL);
+ }
}
+
d(printf("message part kept in memory!\n"));