]> granicus.if.org Git - mutt/commitdiff
Fix GPGME signature zero timestamp and locale awareness issues. (closes #3882)
authorTAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>
Wed, 12 Oct 2016 02:42:14 +0000 (19:42 -0700)
committerTAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>
Wed, 12 Oct 2016 02:42:14 +0000 (19:42 -0700)
GPGME signature information has two minor problems.

[-- Begin signature information --]
*BAD* signature from: Name <user@example.com>
                 aka: Name <user@example.org>
             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.

crypt-gpgme.c

index d5c6f334716b3262aa9792818ee19c7a98ddc813..f7f1d722a51bf3e22ecfc0b2abcc237010a04e1f 100644 (file)
@@ -1345,7 +1345,7 @@ static void show_one_sig_validity (gpgme_ctx_t ctx, int idx, STATE *s)
 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 @@ static void print_smime_keyinfo (const char* msg, gpgme_signature_t sig,
        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 @@ static void print_smime_keyinfo (const char* msg, gpgme_signature_t sig,
     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