[PATCH v2 4/7] cli: sanitize the received header before scanning for replies

Subject: [PATCH v2 4/7] cli: sanitize the received header before scanning for replies

Date: Sat, 30 Nov 2013 17:33:53 +0200

To: notmuch@notmuchmail.org

Cc:

From: Jani Nikula


This makes the from guessing agnostic to header folding by spaces or
tabs.
---
 notmuch-reply.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index ca41405..a2eee17 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -21,6 +21,7 @@
  */
 
 #include "notmuch-client.h"
+#include "string-util.h"
 #include "sprinter.h"
 
 static void
@@ -463,14 +464,21 @@ guess_from_received_header (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_received_for (config, received);
+    sanitized = sanitize_string (config, received);
+    if (! sanitized)
+	return NULL;
+
+    addr = guess_from_received_for (config, sanitized);
     if (! addr)
-	addr = guess_from_received_by (config, received);
+	addr = guess_from_received_by (config, sanitized);
+
+    talloc_free (sanitized);
 
     return addr;
 }
-- 
1.8.4.2


Thread: