diff --git a/agent/ChangeLog b/agent/ChangeLog index d616b1544..8305ec4af 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,8 @@ +2004-08-18 Werner Koch + + * protect-tool.c (get_passphrase): Make sure that the default + prompts passed to gpg-agent are utf-8 encoded. + 2004-07-22 Werner Koch * trustlist.c (read_list): Allow colons in the fingerprint. diff --git a/agent/protect-tool.c b/agent/protect-tool.c index c33d21094..d4c2accfc 100644 --- a/agent/protect-tool.c +++ b/agent/protect-tool.c @@ -29,6 +29,12 @@ #include #include #include +#ifdef HAVE_LOCALE_H +#include +#endif +#ifdef HAVE_LANGINFO_CODESET +#include +#endif #define JNLIB_NEED_LOG_LOGV #include "agent.h" @@ -1138,10 +1144,29 @@ get_passphrase (int promptno) char *pw; int err; const char *desc; + char *orig_codeset = NULL; if (opt_passphrase) return xstrdup (opt_passphrase); +#ifdef ENABLE_NLS + /* The Assuan agent protocol requires us to transmit utf-8 strings */ + orig_codeset = bind_textdomain_codeset (PACKAGE_GT, NULL); +#ifdef HAVE_LANGINFO_CODESET + if (!orig_codeset) + orig_codeset = nl_langinfo (CODESET); +#endif + if (orig_codeset && !strcmp (orig_codeset, "UTF-8")) + orig_codeset = NULL; + if (orig_codeset) + { + /* We only switch when we are able to restore the codeset later. */ + orig_codeset = xstrdup (orig_codeset); + if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) + orig_codeset = NULL; + } +#endif + if (promptno == 1 && opt_prompt) desc = opt_prompt; else @@ -1149,6 +1174,15 @@ get_passphrase (int promptno) "needed to complete this operation."); pw = simple_pwquery (NULL,NULL, _("Passphrase:"), desc, &err); + +#ifdef ENABLE_NLS + if (orig_codeset) + { + bind_textdomain_codeset (PACKAGE_GT, orig_codeset); + xfree (orig_codeset); + } +#endif + if (!pw) { if (err)