[geary/wip/791275-mailsploit-mitigation: 8/8] Indicate spoofed emails in both conversation viewer and list.



commit eb63505aa701a2541b9a4ae45046c53d7276b680
Author: Michael James Gratton <mike vee net>
Date:   Wed Jan 31 16:24:00 2018 +1030

    Indicate spoofed emails in both conversation viewer and list.
    
    Part 3 of Mailsploit mitigation.
    
    * src/client/conversation-list/formatted-conversation-data.vala
      (ParticipantDisplay): Rule a line through spoofed emails.
    
    * src/client/conversation-viewer/conversation-message.vala
      (AddressFlowBoxChild): Display a warning icon and tooltip for spoofed
      addresses.

 .../formatted-conversation-data.vala               |   17 +++++++++++++----
 .../conversation-viewer/conversation-message.vala  |   13 ++++++++++++-
 2 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/src/client/conversation-list/formatted-conversation-data.vala 
b/src/client/conversation-list/formatted-conversation-data.vala
index 03fdab6..2b428e9 100644
--- a/src/client/conversation-list/formatted-conversation-data.vala
+++ b/src/client/conversation-list/formatted-conversation-data.vala
@@ -61,12 +61,21 @@ public class FormattedConversationData : Geary.BaseObject {
             
             return get_as_markup(first_name);
         }
-        
+
         private string get_as_markup(string participant) {
-            return "%s%s%s".printf(
-                is_unread ? "<b>" : "", Geary.HTML.escape_markup(participant), is_unread ? "</b>" : "");
+            string markup = Geary.HTML.escape_markup(participant);
+
+            if (is_unread) {
+                markup = "<b>%s</b>".printf(markup);
+            }
+
+            if (this.address.is_spoofed()) {
+                markup = "<s>%s</s>".printf(markup);
+            }
+
+            return markup;
         }
-        
+
         public bool equal_to(ParticipantDisplay other) {
             return address.equal_to(other.address);
         }
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index ef87805..be6fddb 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -51,6 +51,17 @@ public class ConversationMessage : Gtk.Grid {
 
             Gtk.Grid address_parts = new Gtk.Grid();
 
+            bool is_spoofed = address.is_spoofed();
+            if (is_spoofed) {
+                Gtk.Image spoof_img = new Gtk.Image.from_icon_name(
+                    "dialog-warning-symbolic", Gtk.IconSize.SMALL_TOOLBAR
+                );
+                this.set_tooltip_text(
+                    _("This email address may have been forged")
+                );
+                address_parts.add(spoof_img);
+            }
+
             Gtk.Label primary = new Gtk.Label(null);
             primary.ellipsize = Pango.EllipsizeMode.END;
             primary.set_halign(Gtk.Align.START);
@@ -64,7 +75,7 @@ public class ConversationMessage : Gtk.Grid {
 
             // Don't display the name if it looks spoofed, to reduce
             // chance of the user of being tricked by malware.
-            if (address.has_distinct_name() && !address.is_spoofed()) {
+            if (address.has_distinct_name() && !is_spoofed) {
                 primary.set_text(address.to_short_display());
 
                 Gtk.Label secondary = new Gtk.Label(null);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]