X-Git-Url: https://git.cworth.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage-file.c;h=68f646a4e56d878459d37a665ca0298621e0c1d9;hp=311bd478b0cfff13620ba653795ccb9cd62246bf;hb=HEAD;hpb=c477d7ce311335fda16a15e624ca3931d79144cf diff --git a/lib/message-file.c b/lib/message-file.c index 311bd478..68f646a4 100644 --- a/lib/message-file.c +++ b/lib/message-file.c @@ -64,12 +64,13 @@ _notmuch_message_file_open_ctx (notmuch_database_t *notmuch, if (unlikely (message == NULL)) return NULL; - const char *prefix = notmuch_database_get_path (notmuch); + const char *prefix = notmuch_config_get (notmuch, NOTMUCH_CONFIG_MAIL_ROOT); + if (prefix == NULL) goto FAIL; if (*filename == '/') { - if (strncmp (filename, prefix, strlen(prefix)) != 0) { + if (strncmp (filename, prefix, strlen (prefix)) != 0) { _notmuch_database_log (notmuch, "Error opening %s: path outside mail root\n", filename); errno = 0; @@ -77,7 +78,7 @@ _notmuch_message_file_open_ctx (notmuch_database_t *notmuch, } message->filename = talloc_strdup (message, filename); } else { - message->filename = talloc_asprintf(message, "%s/%s", prefix, filename); + message->filename = talloc_asprintf (message, "%s/%s", prefix, filename); } if (message->filename == NULL) @@ -140,7 +141,6 @@ _notmuch_message_file_parse (notmuch_message_file_t *message) { GMimeParser *parser; notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; - static int initialized = 0; bool is_mbox; if (message->message) @@ -148,10 +148,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message) is_mbox = _is_mbox (message->stream); - if (! initialized) { - g_mime_init (); - initialized = 1; - } + _notmuch_init (); message->headers = g_hash_table_new_full (strcase_hash, strcase_equal, free, g_free); @@ -294,11 +291,16 @@ _notmuch_message_file_get_header (notmuch_message_file_t *message, if (value) return value; - if (strcasecmp (header, "received") == 0) { + if (strcasecmp (header, "received") == 0 || + strcasecmp (header, "delivered-to") == 0) { /* - * The Received: header is special. We concatenate all - * instances of the header as we use this when analyzing the - * path the mail has taken from sender to recipient. + * The Received: header is special. We concatenate all instances of the + * header as we use this when analyzing the path the mail has taken + * from sender to recipient. + * + * Similarly, multiple instances of Delivered-To may be present. We + * concatenate them so the one with highest priority may be picked (eg. + * primary_email before other_email). */ decoded = _notmuch_message_file_get_combined_header (message, header); } else {