[Commits] select-keys.c 1.1.2.31 1.1.2.32

colin at claws-mail.org colin at claws-mail.org
Wed Sep 5 13:38:46 CEST 2012


Update of /home/claws-mail/claws/src/plugins/pgpcore
In directory srv:/tmp/cvs-serv14720/src/plugins/pgpcore

Modified Files:
      Tag: gtk2
	select-keys.c 
Log Message:
2012-09-05 [colin]	3.8.1cvs43

	* src/plugins/pgpcore/select-keys.c
		Fix bug #2390, "Non-fully-trusted-key-warning appears
		based on primary UID rather than recipient e-mail"

Index: select-keys.c
===================================================================
RCS file: /home/claws-mail/claws/src/plugins/pgpcore/Attic/select-keys.c,v
retrieving revision 1.1.2.31
retrieving revision 1.1.2.32
diff -u -d -r1.1.2.31 -r1.1.2.32
--- select-keys.c	27 May 2012 17:31:07 -0000	1.1.2.31
+++ select-keys.c	5 Sep 2012 11:38:44 -0000	1.1.2.32
@@ -83,7 +83,7 @@
 static void sort_keys_name (GtkWidget *widget, gpointer data);
 static void sort_keys_email (GtkWidget *widget, gpointer data);
 
-static gboolean use_untrusted (gpgme_key_t, gpgme_protocol_t proto);
+static gboolean use_untrusted (gpgme_key_t, gpgme_user_id_t uid, gpgme_protocol_t proto);
 
 static void
 update_progress (struct select_keys_s *sk, int running, const char *pattern)
@@ -274,6 +274,7 @@
     int num_results = 0;
     gboolean exact_match = FALSE;
     gpgme_key_t last_key = NULL;
+    gpgme_user_id_t last_uid = NULL;
     cm_return_val_if_fail (sk, NULL);
     clist = sk->clist;
     cm_return_val_if_fail (clist, NULL);
@@ -315,6 +316,7 @@
 		extract_address(raw_mail);
 		if (!strcasecmp(pattern, raw_mail)) {
 			exact_match = TRUE;
+			last_uid = uid;
 			g_free(raw_mail);
 			break;
 		}
@@ -330,7 +332,7 @@
  
     if (exact_match == TRUE && num_results == 1) {
 	    if (last_key->uids->validity < GPGME_VALIDITY_FULL && 
-		!use_untrusted(last_key, proto))
+		!use_untrusted(last_key, last_uid, proto))
 		    exact_match = FALSE;
     }
 
@@ -511,8 +513,25 @@
     row = GPOINTER_TO_INT(sk->clist->selection->data);
     key = gtk_cmclist_get_row_data(sk->clist, row);
     if (key) {
-        if ( key->uids->validity < GPGME_VALIDITY_FULL ) {
-            use_key = use_untrusted(key, sk->proto);
+        gpgme_user_id_t uid;
+	for (uid = key->uids; uid; uid = uid->next) {
+		gchar *raw_mail = NULL;
+
+		if (!uid->email)
+			continue;
+		raw_mail = g_strdup(uid->email);
+		extract_address(raw_mail);
+		if (sk->pattern && !strcasecmp(sk->pattern, raw_mail)) {
+			g_free(raw_mail);
+			break;
+		}
+		g_free(raw_mail);
+	}
+	if (!uid)
+		uid = key->uids;
+
+        if ( uid->validity < GPGME_VALIDITY_FULL ) {
+            use_key = use_untrusted(key, uid, sk->proto);
             if (!use_key) {
                 debug_print ("** Key untrusted, will not encrypt");
                 return;
@@ -578,23 +597,26 @@
 
 
 static gboolean
-use_untrusted (gpgme_key_t key, gpgme_protocol_t proto)
+use_untrusted (gpgme_key_t key, gpgme_user_id_t uid, gpgme_protocol_t proto)
 {
     AlertValue aval;
     gchar *buf = NULL;
-    
+    gchar *title = NULL;
     if (proto != GPGME_PROTOCOL_OpenPGP)
     	return TRUE;
 
-    buf = g_strdup_printf(_("The key of '%s' is not fully trusted.\n"
-	       "If you choose to encrypt the message with this key you don't\n"
-	       "know for sure that it will go to the person you mean it to.\n"
-	       "Do you trust it enough to use it anyway?"), key->uids->email);
+    title = g_strdup_printf(_("Encrypt to %s <%s>"), uid->name, uid->email);
+    buf = g_strdup_printf(_("This encryption key is not fully trusted.\n"
+	       "If you choose to encrypt the message with this key, you don't\n"
+	       "know for sure that it will go to the person you mean it to.\n\n"
+	       "Key details: ID %s, primary identity %s <%s>\n\n"
+	       "Do you trust this key enough to use it anyway?"), 
+	       key->subkeys->keyid, key->uids->name, key->uids->email);
     aval = alertpanel
-	    (_("Trust key"),
-	     buf,
+	    (title, buf,
 	     GTK_STOCK_NO, GTK_STOCK_YES, NULL);
     g_free(buf);
+    g_free(title);
     if (aval == G_ALERTALTERNATE)
 	return TRUE;
     else



More information about the Commits mailing list