diff options
| author | Carl Worth <cworth@cworth.org> | 2009-10-19 23:08:49 -0700 |
|---|---|---|
| committer | Carl Worth <cworth@cworth.org> | 2009-10-19 23:16:05 -0700 |
| commit | ad784f38ce30d39b058325baf050eb784fb9a02e (patch) | |
| tree | 2403422f5d17070ce77ff4fdf920a799d5803432 /message.c | |
| parent | b6dd413903370bd9b4f50428a32276f1f8457937 (diff) | |
notmuch: Ignore files that don't look like email messages.
This is helpful for things like indexes that other mail programs
may have left around. It also means we can make the initial
instructions much easier, (the user need not worry about moving
away auxiliary files from some other email program).
Diffstat (limited to 'message.c')
| -rw-r--r-- | message.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -37,6 +37,8 @@ struct _notmuch_message { /* Header storage */ int restrict_headers; GHashTable *headers; + int broken_headers; + int good_headers; /* Parsing state */ char *line; @@ -234,12 +236,21 @@ notmuch_message_get_header (notmuch_message_t *message, colon = strchr (message->line, ':'); if (colon == NULL) { - fprintf (stderr, "Warning: Unexpected non-header line: %s\n", - message->line); + message->broken_headers++; + /* A simple heuristic for giving up on things that just + * don't look like mail messages. */ + if (message->broken_headers >= 10 && + message->good_headers < 5) + { + message->parsing_finished = 1; + continue; + } NEXT_HEADER_LINE (NULL); continue; } + message->good_headers++; + header = xstrndup (message->line, colon - message->line); if (message->restrict_headers && |
