diff options
-rw-r--r-- | camel/ChangeLog | 6 | ||||
-rw-r--r-- | camel/camel-gpg-context.c | 23 |
2 files changed, 25 insertions, 4 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 631cf205c3..d5c01bbca9 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2003-11-04 Jeffrey Stedfast <fejj@ximian.com> + + * camel-gpg-context.c (gpg_ctx_parse_status): We might need to + convert the passwd from UTF-8 into the locale charset. Fixes bug + #50485. + 2003-10-31 Not Zed <NotZed@Ximian.com> * camel-cms-context.[ch]: removed, now redundant. diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 6f79cdb4ff..ea27ac2926 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -208,7 +208,9 @@ struct _GpgCtx { unsigned int diagflushed:1; - unsigned int padding:17; + unsigned int utf8:1; + + unsigned int padding:16; }; static struct _GpgCtx * @@ -266,6 +268,8 @@ gpg_ctx_new (CamelSession *session) CamelMimeFilterCharset *filter; CamelStreamFilter *fstream; + gpg->utf8 = FALSE; + if ((filter = camel_mime_filter_charset_new_convert (charset, "UTF-8"))) { fstream = camel_stream_filter_new_with_stream (stream); camel_stream_filter_add (fstream, (CamelMimeFilter *) filter); @@ -274,6 +278,8 @@ gpg_ctx_new (CamelSession *session) stream = (CamelStream *) fstream; } + } else { + gpg->utf8 = TRUE; } gpg->diagnostics = stream; @@ -663,6 +669,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) { register unsigned char *inptr; const unsigned char *status; + size_t nread, nwritten; int len; parse: @@ -691,7 +698,6 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) status += 9; if (!strncmp (status, "USERID_HINT ", 12)) { - size_t nread, nwritten; char *hint, *user; status += 12; @@ -708,7 +714,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) goto recycle; } - if (!(user = g_locale_to_utf8 (status, -1, &nread, &nwritten, NULL))) + if (gpg->utf8 || !(user = g_locale_to_utf8 (status, -1, &nread, &nwritten, NULL))) user = g_strdup (status); g_strstrip (user); @@ -734,7 +740,16 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) prompt = g_strdup_printf (_("You need a passphrase to unlock the key for\n" "user: \"%s\""), name); - passwd = camel_session_get_password (gpg->session, prompt, FALSE, TRUE, NULL, userid, ex); + if ((passwd = camel_session_get_password (gpg->session, prompt, FALSE, TRUE, NULL, userid, ex)) && !gpg->utf8) { + char *opasswd = passwd; + + if ((passwd = g_locale_to_utf8 (passwd, -1, &nread, &nwritten, NULL))) { + memset (opasswd, 0, strlen (opasswd)); + g_free (opasswd); + } else { + passwd = opasswd; + } + } g_free (prompt); g_free (gpg->userid); |