diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-11-05 05:52:59 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-11-05 05:52:59 +0800 |
commit | 0c29bfd43c82a09225733235db2d9cd9a79b07ae (patch) | |
tree | 59174c9333b4a5f9cd9f92000d377264652eb7d6 /camel/camel-gpg-context.c | |
parent | 40d492ac4bd66131e87cf75c678eea500519aa47 (diff) | |
download | gsoc2013-evolution-0c29bfd43c82a09225733235db2d9cd9a79b07ae.tar gsoc2013-evolution-0c29bfd43c82a09225733235db2d9cd9a79b07ae.tar.gz gsoc2013-evolution-0c29bfd43c82a09225733235db2d9cd9a79b07ae.tar.bz2 gsoc2013-evolution-0c29bfd43c82a09225733235db2d9cd9a79b07ae.tar.lz gsoc2013-evolution-0c29bfd43c82a09225733235db2d9cd9a79b07ae.tar.xz gsoc2013-evolution-0c29bfd43c82a09225733235db2d9cd9a79b07ae.tar.zst gsoc2013-evolution-0c29bfd43c82a09225733235db2d9cd9a79b07ae.zip |
We might need to convert the passwd from UTF-8 into the locale charset.
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.
svn path=/trunk/; revision=23186
Diffstat (limited to 'camel/camel-gpg-context.c')
-rw-r--r-- | camel/camel-gpg-context.c | 23 |
1 files changed, 19 insertions, 4 deletions
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); |