[git] Pinentry - branch, master, updated. pinentry-1.1.0-14-g21f0883
by Damien Goutte-Gattat
cvs at cvs.gnupg.org
Sun Feb 10 19:33:39 CET 2019
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The standard pinentry collection".
The branch, master has been updated
via 21f0883059c84de7145d402877cd178fcfed44e3 (commit)
via a60e4f8142159b3e2df10d8d725b9680be5b4616 (commit)
from d0eaec8ef60be9b4d1aa5993c11d261a35202a2e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 21f0883059c84de7145d402877cd178fcfed44e3
Author: Damien Goutte-Gattat <dgouttegattat at incenp.org>
Date: Thu Feb 7 23:03:03 2019 +0000
fltk: Handle '_' in button labels as keyboard shortcuts.
* fltk/main.cxx (convert_accel_utf8): New method.
(fltk_cmd_handler): Calls previous method to escape button labels.
GnuPG-bug-id: 4336
Signed-off-by: Damien Goutte-Gattat <dgouttegattat at incenp.org>
Co-authored-by: Michael Bäuerle
diff --git a/fltk/main.cxx b/fltk/main.cxx
index 5d226ed..2afad1c 100644
--- a/fltk/main.cxx
+++ b/fltk/main.cxx
@@ -78,6 +78,44 @@ static std::string escape_accel_utf8(const char *s)
return result;
}
+// For button labels
+// Accelerator '_' (used e.g. by GPG2) is converted to '&' (for FLTK)
+// '&' is escaped as in escape_accel_utf8()
+static std::string convert_accel_utf8(const char *s)
+{
+ static bool last_was_underscore = false;
+ std::string result;
+ if (NULL != s)
+ {
+ result.reserve(strlen(s));
+ for (const char *p = s; *p; ++p)
+ {
+ // & => &&
+ if ('&' == *p)
+ result.push_back(*p);
+ // _ => & (handle '__' as escaped underscore)
+ if ('_' == *p)
+ {
+ if (last_was_underscore)
+ {
+ result.push_back(*p);
+ last_was_underscore = false;
+ }
+ else
+ last_was_underscore = true;
+ }
+ else
+ {
+ if (last_was_underscore)
+ result.push_back('&');
+ result.push_back(*p);
+ last_was_underscore = false;
+ }
+ }
+ }
+ return result;
+}
+
class cancel_exception
{
@@ -111,8 +149,8 @@ static int fltk_cmd_handler(pinentry_t pe)
// TODO: Add parent window to pinentry-fltk window
//if (pe->parent_wid){}
std::string title = !is_empty(pe->title)?pe->title:PGMNAME;
- std::string ok = escape_accel_utf8(pe->ok?pe->ok:(pe->default_ok?pe->default_ok:OK_STRING));
- std::string cancel = escape_accel_utf8(pe->cancel?pe->cancel:(pe->default_cancel?pe->default_cancel:CANCEL_STRING));
+ std::string ok = convert_accel_utf8(pe->ok?pe->ok:(pe->default_ok?pe->default_ok:OK_STRING));
+ std::string cancel = convert_accel_utf8(pe->cancel?pe->cancel:(pe->default_cancel?pe->default_cancel:CANCEL_STRING));
if (!!pe->pin) // password (or confirmation)
{
commit a60e4f8142159b3e2df10d8d725b9680be5b4616
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date: Thu Feb 7 23:11:19 2019 +0000
fltk: Fix formatting escapes.
* fltk/main.cxx (fltk_cmd_handler): Fix calls to fl_message()
and fl_choice() functions.
--
The fl_message and fl_choice functions expect a format string as
their first argument; passing the message directly might cause a
crash (or worse) if the message happens to contain formatting
escape chars.
GnuPG-bug-id: 4337
Signed-off-by: Damien Goutte-Gattat <dgouttegattat at incenp.org>
diff --git a/fltk/main.cxx b/fltk/main.cxx
index 8e7e726..5d226ed 100644
--- a/fltk/main.cxx
+++ b/fltk/main.cxx
@@ -241,12 +241,12 @@ static int fltk_cmd_handler(pinentry_t pe)
if (pe->one_button)
{
fl_ok = ok.c_str();
- fl_message(message);
+ fl_message("%s", message);
result = 1; // OK
}
else if (pe->notok)
{
- switch (fl_choice(message, ok.c_str(), cancel.c_str(), pe->notok))
+ switch (fl_choice("%s", ok.c_str(), cancel.c_str(), pe->notok, message))
{
case 0: result = 1; break;
case 2: result = 0; break;
@@ -256,7 +256,7 @@ static int fltk_cmd_handler(pinentry_t pe)
}
else
{
- switch (fl_choice(message, ok.c_str(), cancel.c_str(), NULL))
+ switch (fl_choice("%s", ok.c_str(), cancel.c_str(), NULL, message))
{
case 0: result = 1; break;
default:
-----------------------------------------------------------------------
Summary of changes:
fltk/main.cxx | 48 +++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 43 insertions(+), 5 deletions(-)
hooks/post-receive
--
The standard pinentry collection
http://git.gnupg.org
More information about the Gnupg-commits
mailing list