lib: Perform the same transformation to _notmuch_database_find_directory_id
[notmuch] / lib / message-file.c
index 7722832e9158411e8101f21cb163f0f0051b9854..915aba8bf97bb1b1e1251c3a3c4a161d81912bd8 100644 (file)
@@ -329,7 +329,7 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
        /* we treat the Received: header special - we want to concat ALL of 
         * the Received: headers we encounter.
         * for everything else we return the first instance of a header */
-       if (is_received) {
+       if (strcasecmp(header, "received") == 0) {
            if (header_sofar == NULL) {
                /* first Received: header we encountered; just add it */
                g_hash_table_insert (message->headers, header, decoded_value);
@@ -341,12 +341,17 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
                strncpy(combined_header,header_sofar,hdrsofar);
                *(combined_header+hdrsofar) = ' ';
                strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);
+               free (decoded_value);
                g_hash_table_insert (message->headers, header, combined_header);
            }
        } else {
            if (header_sofar == NULL) {
                /* Only insert if we don't have a value for this header, yet. */
                g_hash_table_insert (message->headers, header, decoded_value);
+           } else {
+               free (header);
+               free (decoded_value);
+               decoded_value = header_sofar;
            }
        }
        /* if we found a match we can bail - unless of course we are