1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

(get_passphrase): Make sure that the default

prompts passed to gpg-agent are utf-8 encoded.
This commit is contained in:
Werner Koch 2004-08-18 12:47:33 +00:00
parent 9d864ebef7
commit aac85ca314
2 changed files with 39 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2004-08-18 Werner Koch <wk@g10code.de>
* protect-tool.c (get_passphrase): Make sure that the default
prompts passed to gpg-agent are utf-8 encoded.
2004-07-22 Werner Koch <wk@g10code.de>
* trustlist.c (read_list): Allow colons in the fingerprint.

View File

@ -29,6 +29,12 @@
#include <assert.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#ifdef HAVE_LANGINFO_CODESET
#include <langinfo.h>
#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)