]> git.notmuchmail.org Git - notmuch/commitdiff
notmuch setup: Collapse internal whitespace within message-id
authorCarl Worth <cworth@cworth.org>
Wed, 21 Oct 2009 17:07:34 +0000 (10:07 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 21 Oct 2009 17:07:34 +0000 (10:07 -0700)
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.

database.cc

index 31afe7cc147afdc3098e8599eb57337b7c7b785d..1aef2a966ec3fb431ff3b6f92735f0fdb57f4326 100644 (file)
@@ -305,6 +305,7 @@ static char *
 parse_message_id (const char *message_id, const char **next)
 {
     const char *s, *end;
 parse_message_id (const char *message_id, const char **next)
 {
     const char *s, *end;
+    char *result;
 
     if (message_id == NULL)
        return NULL;
 
     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 && *end == '>')
        end--;
-    if (end > s)
-       return strndup (s, end - s + 1);
-    else
+    if (end <= s)
        return NULL;
        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
 }
 
 /* Parse a References header value, putting a copy of each referenced