aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-04-10 06:04:33 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-04-10 06:04:33 +0800
commit14517cbca46e86fdb825a2ac6df35808290df99f (patch)
treea439791d146e3088ca635fc9843748a605ea3b2e
parent94286866e7f748254b0f3ec70e4a52b729bc4dd0 (diff)
downloadgsoc2013-evolution-14517cbca46e86fdb825a2ac6df35808290df99f.tar
gsoc2013-evolution-14517cbca46e86fdb825a2ac6df35808290df99f.tar.gz
gsoc2013-evolution-14517cbca46e86fdb825a2ac6df35808290df99f.tar.bz2
gsoc2013-evolution-14517cbca46e86fdb825a2ac6df35808290df99f.tar.lz
gsoc2013-evolution-14517cbca46e86fdb825a2ac6df35808290df99f.tar.xz
gsoc2013-evolution-14517cbca46e86fdb825a2ac6df35808290df99f.tar.zst
gsoc2013-evolution-14517cbca46e86fdb825a2ac6df35808290df99f.zip
Changed my mind a bit on how I wanted this to work. Instead of aborting on
2003-04-09 Jeffrey Stedfast <fejj@ximian.com> * camel-gpg-context.c (gpg_ctx_get_utf8_diagnostics): Changed my mind a bit on how I wanted this to work. Instead of aborting on an illegal sequence, do like we do with camel-mime-filter-charset and just skip over invalid sequences. Also, in the noop failure case, close the iconv_t so we don't leak it. svn path=/trunk/; revision=20796
-rw-r--r--camel/ChangeLog6
-rw-r--r--camel/camel-gpg-context.c68
2 files changed, 45 insertions, 29 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 051531b8c7..f07d3c83f3 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,11 @@
2003-04-09 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-gpg-context.c (gpg_ctx_get_utf8_diagnostics): Changed my
+ mind a bit on how I wanted this to work. Instead of aborting on an
+ illegal sequence, do like we do with camel-mime-filter-charset and
+ just skip over invalid sequences. Also, in the noop failure case,
+ close the iconv_t so we don't leak it.
+
* providers/imap/camel-imap-utils.c (imap_body_decode): Save the
content size in a temp variable until after we've successfully
parsed all of the body_type_1part expr. Also fixed a type-o in the
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index 7a4098a3df..ad60f88fd3 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -428,39 +428,48 @@ gpg_ctx_get_utf8_diagnostics (struct _GpgCtx *gpg)
inbuf = gpg->diagnostics->data;
inleft = gpg->diagnostics->len;
- outlen = (inleft * 2) + 16;
- out = g_malloc (outlen + 1);
+ outleft = outlen = (inleft * 2) + 16;
+ outbuf = out = g_malloc (outlen + 1);
do {
- outbuf = out + converted;
- outleft = outlen - converted;
-
converted = e_iconv (cd, &inbuf, &inleft, &outbuf, &outleft);
if (converted == (size_t) -1) {
- if (errno != E2BIG && errno != EINVAL)
- goto fail;
- }
-
- /*
- * E2BIG There is not sufficient room at *outbuf.
- *
- * We just need to grow our outbuffer and try again.
- */
-
- converted = outbuf - out;
- if (errno == E2BIG) {
- outlen += inleft * 2 + 16;
- out = g_realloc (out, outlen + 1);
- outbuf = out + converted;
+ if (errno == E2BIG) {
+ /*
+ * E2BIG There is not sufficient room at *outbuf.
+ *
+ * We just need to grow our outbuffer and try again.
+ */
+
+ converted = outbuf - out;
+ outlen += inleft * 2 + 16;
+ out = g_realloc (out, outlen + 1);
+ outbuf = out + converted;
+ outleft = outlen - converted;
+ } else if (errno == EILSEQ) {
+ /*
+ * EILSEQ An invalid multibyte sequence has been encountered
+ * in the input.
+ *
+ * What we do here is eat the invalid bytes in the sequence and continue
+ */
+
+ inbuf++;
+ inleft--;
+ } else if (errno == EINVAL) {
+ /*
+ * EINVAL An incomplete multibyte sequence has been encounĀ­
+ * tered in the input.
+ *
+ * We assume that this can only happen if we've run out of
+ * bytes for a multibyte sequence, if not we're in trouble.
+ */
+
+ break;
+ } else
+ goto noop;
}
- } while (errno == E2BIG && inleft > 0);
-
- /*
- * EINVAL An incomplete multibyte sequence has been encounĀ­
- * tered in the input.
- *
- * We'll just have to ignore it...
- */
+ } while (((int) inleft) > 0);
/* flush the iconv conversion */
e_iconv (cd, NULL, NULL, &outbuf, &outleft);
@@ -471,9 +480,10 @@ gpg_ctx_get_utf8_diagnostics (struct _GpgCtx *gpg)
return out;
- fail:
+ noop:
g_free (out);
+ e_iconv_close (cd);
return gpg_ctx_get_diagnostics (gpg);
}