diff options
author | Carl Worth <cworth@cworth.org> | 2009-10-21 10:07:34 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-10-21 10:07:34 -0700 |
commit | d29a6ec79167e87e4958d9500956668c430db4c6 (patch) | |
tree | f70f129d7e40ef140407d79b528a88553f6b551a | |
parent | 65baa4f4e7fc401e5af742b491a3bc0784f2cdf7 (diff) |
notmuch setup: Collapse internal whitespace within message-id
I'm too lazy to see what the RFC says, but I know that having
whitespace inside a message-ID is sure to confuse things. And
besides, this makes things more compatible with sup so that
I have some hope of importing sup labels.
-rw-r--r-- | database.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/database.cc b/database.cc index 31afe7c..1aef2a9 100644 --- a/database.cc +++ b/database.cc @@ -305,6 +305,7 @@ static char * parse_message_id (const char *message_id, const char **next) { const char *s, *end; + char *result; if (message_id == NULL) return NULL; @@ -339,10 +340,23 @@ parse_message_id (const char *message_id, const char **next) if (end > s && *end == '>') end--; - if (end > s) - return strndup (s, end - s + 1); - else + if (end <= s) return NULL; + + result = strndup (s, end - s + 1); + + /* Finally, collapse any whitespace that is within the message-id + * itself. */ + { + char *r; + int len; + + for (r = result, len = strlen (r); *r; r++, len--) + if (*r == ' ' || *r == '\t') + memmove (r, r+1, len); + } + + return result; } /* Parse a References header value, putting a copy of each referenced |