cli: sanitize the received header before scanning for replies
authorJani Nikula <jani@nikula.org>
Wed, 19 Mar 2014 16:44:50 +0000 (18:44 +0200)
committerDavid Bremner <david@tethera.net>
Wed, 26 Mar 2014 00:22:03 +0000 (21:22 -0300)
This makes the from guessing agnostic to header folding by spaces or
tabs.

notmuch-reply.c

index 47993d223090ee423b7c42126122dcd688215c8b..7c1c80959ed6cee221479353bbb84345a6875055 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "notmuch-client.h"
+#include "string-util.h"
 #include "sprinter.h"
 
 static void
@@ -465,14 +466,21 @@ guess_from_in_received_headers (notmuch_config_t *config,
                                notmuch_message_t *message)
 {
     const char *received, *addr;
+    char *sanitized;
 
     received = notmuch_message_get_header (message, "received");
     if (! received)
        return NULL;
 
-    addr = guess_from_in_received_for (config, received);
+    sanitized = sanitize_string (NULL, received);
+    if (! sanitized)
+       return NULL;
+
+    addr = guess_from_in_received_for (config, sanitized);
     if (! addr)
-       addr = guess_from_in_received_by (config, received);
+       addr = guess_from_in_received_by (config, sanitized);
+
+    talloc_free (sanitized);
 
     return addr;
 }