changeset: 6815:7c0995a61268 user: TAKAHASHI Tamotsu <[email protected]> date: Tue Oct 11 19:42:14 2016 -0700 link: http://dev.mutt.org/hg/mutt/rev/7c0995a61268
Fix GPGME signature zero timestamp and locale awareness issues. (closes #3882) GPGME signature information has two minor problems. [-- Begin signature information --] *BAD* signature from: Name <[email protected]> aka: Name <[email protected]> created: Thu Jan 1 09:00:00 1970 [-- End signature information --] First, the created timestamp is incorrect when the message is not verified successfully. Second, as the code itself has some "TODO" comments, "aka" and "created" lines are not properly-aligned when LC_MESSAGES != English. diffs (55 lines): diff -r 33d16ccba4cf -r 7c0995a61268 crypt-gpgme.c --- a/crypt-gpgme.c Mon Oct 10 18:09:00 2016 -0700 +++ b/crypt-gpgme.c Tue Oct 11 19:42:14 2016 -0700 @@ -1345,7 +1345,7 @@ static void print_smime_keyinfo (const char* msg, gpgme_signature_t sig, gpgme_key_t key, STATE *s) { - size_t msglen; + int msgwid; gpgme_user_id_t uids = NULL; int i, aka = 0; @@ -1360,10 +1360,10 @@ continue; if (aka) { - /* TODO: need to account for msg wide characters - * and "aka" translation length */ - msglen = mutt_strlen (msg) - 4; - for (i = 0; i < msglen; i++) + msgwid = mutt_strwidth (msg) - mutt_strwidth (_("aka: ")) + 1; + if (msgwid < 0) + msgwid = 0; + for (i = 0; i < msgwid; i++) state_puts(" ", s); state_puts(_("aka: "), s); } @@ -1380,14 +1380,19 @@ state_puts ("\n", s); } - msglen = mutt_strlen (msg) - 8; - /* TODO: need to account for msg wide characters - * and "created" translation length */ - for (i = 0; i < msglen; i++) - state_puts(" ", s); - state_puts (_("created: "), s); - print_time (sig->timestamp, s); - state_puts ("\n", s); + /* timestamp is 0 when verification failed. + "Jan 1 1970" is not the created date. */ + if (sig->timestamp) + { + msgwid = mutt_strwidth (msg) - mutt_strwidth (_("created: ")) + 1; + if (msgwid < 0) + msgwid = 0; + for (i = 0; i < msgwid; i++) + state_puts(" ", s); + state_puts (_("created: "), s); + print_time (sig->timestamp, s); + state_puts ("\n", s); + } } /* Show information about one signature. This function is called with
