X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage-id.c;h=e71ce9f4674465c13f06eee32c4266d8821b3a26;hp=d7541d50102d671ca6fd465ff047ceb4c220753a;hb=bbe3015b3ea503b2834811f6cdd7276f9742faa1;hpb=2f4beda434c59f9e2f5b7c32d26543bad7217ad4 diff --git a/lib/message-id.c b/lib/message-id.c index d7541d50..e71ce9f4 100644 --- a/lib/message-id.c +++ b/lib/message-id.c @@ -1,4 +1,5 @@ #include "notmuch-private.h" +#include "string-util.h" /* Advance 'str' past any whitespace or RFC 822 comments. A comment is * a (potentially nested) parenthesized sequence with '\' used to @@ -94,3 +95,32 @@ _notmuch_message_id_parse (void *ctx, const char *message_id, const char **next) return result; } + +char * +_notmuch_message_id_parse_strict (void *ctx, const char *message_id) +{ + const char *s, *end; + + if (message_id == NULL || *message_id == '\0') + return NULL; + + s = skip_space (message_id); + if (*s == '<') + s++; + else + return NULL; + + for (end = s; *end && *end != '>'; end++) + if (isspace (*end)) + return NULL; + + if (*end != '>') + return NULL; + else { + const char *last = skip_space (end + 1); + if (*last != '\0') + return NULL; + } + + return talloc_strndup (ctx, s, end - s); +}