diff options
author | NotZed <NotZed@HelixCode.com> | 2000-05-03 12:20:26 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-05-03 12:20:26 +0800 |
commit | ff8bc3108abda5bcb07fb5417d8dac5bdbd39fa1 (patch) | |
tree | ac2ac318eb64cdc83c97d690ca9f737e5e2e2b66 /camel/camel-mime-utils.c | |
parent | af1a6bcf6a053de4ece5a4ea4345699bc296e3ad (diff) | |
download | gsoc2013-evolution-ff8bc3108abda5bcb07fb5417d8dac5bdbd39fa1.tar gsoc2013-evolution-ff8bc3108abda5bcb07fb5417d8dac5bdbd39fa1.tar.gz gsoc2013-evolution-ff8bc3108abda5bcb07fb5417d8dac5bdbd39fa1.tar.bz2 gsoc2013-evolution-ff8bc3108abda5bcb07fb5417d8dac5bdbd39fa1.tar.lz gsoc2013-evolution-ff8bc3108abda5bcb07fb5417d8dac5bdbd39fa1.tar.xz gsoc2013-evolution-ff8bc3108abda5bcb07fb5417d8dac5bdbd39fa1.tar.zst gsoc2013-evolution-ff8bc3108abda5bcb07fb5417d8dac5bdbd39fa1.zip |
If the iconv handle is -1, then dont try and convert (crashes
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.
svn path=/trunk/; revision=2774
Diffstat (limited to 'camel/camel-mime-utils.c')
-rw-r--r-- | camel/camel-mime-utils.c | 27 |
1 files changed, 17 insertions, 10 deletions
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)); |