aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog10
-rw-r--r--camel/camel-mime-utils.c27
2 files changed, 27 insertions, 10 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index d65d890542..d2aec28651 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,13 @@
+2000-05-03 NotZed <NotZed@HelixCode.com>
+
+ * camel-mime-utils.c (rfc2047_decode_word): If the iconv handle is
+ -1, then dont try and convert (crashes unicode_iconv?).
+ (rfc2047_decode_word): Use alloca for variables instead of
+ g_malloc - by the rfc they should always be short.
+ (rfc2047_decode_word): If we can't do the charset conversion, undo
+ the quoted-printable/base64 at least? Should probably convert
+ unknown characters to the utf-8 unknown character.
+
2000-05-02 Larry Ewing <lewing@helixcode.com>
* camel-mime-utils.c (header_decode_date): fix typo when
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 6c9645b6c8..3f4c4d99d3 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -680,9 +680,10 @@ rfc2047_decode_word(const char *in, int len)
if (inptr!=NULL
&& inptr<inend+2
&& inptr[2]=='?') {
+ d(printf("found ?, encoding is '%c'\n", inptr[0]));
inptr++;
tmplen = inend-inptr-2;
- decword = g_malloc(tmplen); /* this will always be more-than-enough room */
+ decword = alloca(tmplen); /* this will always be more-than-enough room */
switch(toupper(inptr[0])) {
case 'Q':
inlen = quoted_decode(inptr+2, tmplen, decword);
@@ -695,6 +696,7 @@ rfc2047_decode_word(const char *in, int len)
break;
}
}
+ d(printf("The encoded length = %d\n", inlen));
if (inlen>0) {
/* yuck, all this snot is to setup iconv! */
tmplen = inptr-in-3;
@@ -705,21 +707,26 @@ rfc2047_decode_word(const char *in, int len)
inbuf = decword;
outlen = inlen*6;
- outbase = g_malloc(outlen);
+ outbase = alloca(outlen);
outbuf = outbase;
+ /* TODO: Should this cache iconv converters? */
ic = unicode_iconv_open("utf-8", encname);
- ret = unicode_iconv(ic, (const char **)&inbuf, &inlen, &outbuf, &outlen);
- unicode_iconv_close(ic);
- if (ret>=0) {
- *outbuf = 0;
- decoded = outbase;
- outbase = NULL;
+ if (ic != (unicode_iconv_t)-1) {
+ ret = unicode_iconv(ic, (const char **)&inbuf, &inlen, &outbuf, &outlen);
+ unicode_iconv_close(ic);
+ if (ret>=0) {
+ *outbuf = 0;
+ decoded = g_strdup(outbase);
+ }
+ } else {
+ g_warning("Cannot decode charset, header display may be corrupt: %s: %s", encname, strerror(errno));
+ /* TODO: Should this do this, or just leave the encoded strings? */
+ decword[inlen] = 0;
+ decoded = g_strdup(decword);
}
}
}
- free(outbase);
- free(decword);
d(printf("decoded '%s'\n", decoded));