cli: sanitize the received header before scanning for replies

This makes the from guessing agnostic to header folding by spaces or
tabs.
This commit is contained in:
Jani Nikula 2014-03-19 18:44:50 +02:00 committed by David Bremner
parent b6238f7e51
commit 31a6333aa4

View file

@ -21,6 +21,7 @@
*/ */
#include "notmuch-client.h" #include "notmuch-client.h"
#include "string-util.h"
#include "sprinter.h" #include "sprinter.h"
static void static void
@ -465,14 +466,21 @@ guess_from_in_received_headers (notmuch_config_t *config,
notmuch_message_t *message) notmuch_message_t *message)
{ {
const char *received, *addr; const char *received, *addr;
char *sanitized;
received = notmuch_message_get_header (message, "received"); received = notmuch_message_get_header (message, "received");
if (! received) if (! received)
return NULL; 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) if (! addr)
addr = guess_from_in_received_by (config, received); addr = guess_from_in_received_by (config, sanitized);
talloc_free (sanitized);
return addr; return addr;
} }