aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-07-25 06:23:40 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-07-25 06:23:40 +0800
commit443f0aba47fb02df592e43a5933b19dcb8b6021d (patch)
treeb04a7d4a6c7c37368c091a6bed5f420343e88da6 /camel
parent1c1a9d017772e790a241e79e51262980e98afa56 (diff)
downloadgsoc2013-evolution-443f0aba47fb02df592e43a5933b19dcb8b6021d.tar
gsoc2013-evolution-443f0aba47fb02df592e43a5933b19dcb8b6021d.tar.gz
gsoc2013-evolution-443f0aba47fb02df592e43a5933b19dcb8b6021d.tar.bz2
gsoc2013-evolution-443f0aba47fb02df592e43a5933b19dcb8b6021d.tar.lz
gsoc2013-evolution-443f0aba47fb02df592e43a5933b19dcb8b6021d.tar.xz
gsoc2013-evolution-443f0aba47fb02df592e43a5933b19dcb8b6021d.tar.zst
gsoc2013-evolution-443f0aba47fb02df592e43a5933b19dcb8b6021d.zip
Handle broken mailers that send unencoded 8bit header params. And there
2001-07-24 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-utils.c (header_decode_param): Handle broken mailers that send unencoded 8bit header params. And there was much rejoicing. Rah. svn path=/trunk/; revision=11362
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog4
-rw-r--r--camel/camel-mime-utils.c37
2 files changed, 41 insertions, 0 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 59cadc3f9a..549841417e 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,9 @@
2001-07-24 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-mime-utils.c (header_decode_param): Handle broken mailers
+ that send unencoded 8bit header params. And there was much
+ rejoicing. Rah.
+
* camel-url.h (CAMEL_URL_HIDE_ALL): New #define, and there was
much rejoicing. Rah.
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index e5c90dabd0..f8e4745400 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -1970,6 +1970,43 @@ header_decode_param (const char **in, char **paramp, char **valuep, int *is_rfc2
}
}
+ if (!g_utf8_validate (value, -1, NULL)) {
+ /* The (broken) mailer sent us an unencoded 8bit value
+ * attempt to save it by assuming it's in the user's
+ * locale and converting to utf8 */
+ char *outbase, *outbuf, *p;
+ const char *inbuf;
+ int inlen, outlen;
+ iconv_t ic;
+
+ inbuf = value;
+ inlen = strlen (inbuf);
+
+ ic = iconv_open ("UTF-8", camel_charset_locale_name ());
+ if (ic != (iconv_t) -1) {
+ int ret;
+
+ outlen = inlen * 6 + 16;
+ outbuf = outbase = g_malloc (outlen);
+
+ ret = iconv (ic, &inbuf, &inlen, &outbuf, &outlen);
+ if (ret >= 0) {
+ iconv (ic, NULL, 0, &outbuf, &outlen);
+ *outbuf = '\0';
+ }
+
+ iconv_close (ic);
+
+ g_free (value);
+ value = outbase;
+ } else {
+ /* Okay, so now what? I guess we convert invalid chars to _'s? */
+ for (p = value; *p; p++)
+ if (!isascii ((unsigned) *p))
+ *p = '_';
+ }
+ }
+
if (param && value) {
*paramp = param;
*valuep = value;