X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-mime%2Frfc822parse.c;h=adc73d9a5c5b447133f7abf5e27cd0b2093aa542;hb=fa4c2af84416f9b4663bb80d36faaba35db05524;hp=6a3c1640ad1dbbc903f3dc85a746681512ce704e;hpb=89a7d4396b35e8047cbe519e81e22d99a1efd018;p=apps%2Fmadmutt.git diff --git a/lib-mime/rfc822parse.c b/lib-mime/rfc822parse.c index 6a3c164..adc73d9 100644 --- a/lib-mime/rfc822parse.c +++ b/lib-mime/rfc822parse.c @@ -102,62 +102,65 @@ ssize_t mutt_read_rfc822_line(FILE *f, char **line, ssize_t *n) } } -LIST *mutt_parse_references (char *s, int in_reply_to) +/* TODO: Make that a string list somehow */ +LIST *mutt_parse_references(char *s, int in_reply_to) { - LIST *t, *lst = NULL; - int m, n = 0; - char *o = NULL, *new, *at; + LIST *lst = NULL; + int n = 0; + char *o = NULL; - while ((s = strtok (s, " \t;")) != NULL) { - /* - * some mail clients add other garbage besides message-ids, so do a quick + /* some mail clients add other garbage besides message-ids, so do a quick * check to make sure this looks like a valid message-id * some idiotic clients also break their message-ids between lines, deal * with that too (give up if it's more than two lines, though) */ - t = NULL; - new = NULL; - - if (*s == '<') { - n = m_strlen(s); - if (s[n - 1] != '>') { - o = s; - s = NULL; - continue; - } - new = m_strdup(s); - } - else if (o) { - m = m_strlen(s); - if (s[m - 1] == '>') { - new = p_new(char, n + m + 1); - strcpy (new, o); /* __STRCPY_CHECKED__ */ - strcpy (new + n, s); /* __STRCPY_CHECKED__ */ - } - } - if (new) { - /* make sure that this really does look like a message-id. - * it should have exactly one @, and if we're looking at - * an in-reply-to header, make sure that the part before - * the @ has more than eight characters or it's probably - * an email address - */ - if (!(at = strchr (new, '@')) || strchr (at + 1, '@') - || (in_reply_to && at - new <= 8)) - p_delete(&new); - else { - t = p_new(LIST, 1); - t->data = new; - t->next = lst; - lst = t; - } + for (s = strtok(s, " \t;"); s; s = strtok(NULL, " \t;")) { + char *new = NULL; + + if (*s == '<') { + n = m_strlen(s); + if (s[n - 1] != '>') { + o = s; + continue; + } + + new = m_strdup(s); + } else if (o) { + ssize_t m = m_strlen(s); + + if (s[m - 1] != '>') { + o = NULL; + } else { + new = p_new(char, n + m + 1); + strcpy(new, o); + strcpy(new + n, s); + } + } + + /* make sure that this really does look like a message-id. + * it should have exactly one @, and if we're looking at + * an in-reply-to header, make sure that the part before + * the @ has more than eight characters or it's probably + * an email address + */ + if (new) { + char *at = strchr(new, '@'); + LIST *tmp; + + if (!at || strchr(at + 1, '@') || (in_reply_to && at - new <= 8)) { + p_delete(&new); + continue; + } + + tmp = p_new(LIST, 1); + tmp->data = new; + tmp->next = lst; + lst = tmp; + } } - o = NULL; - s = NULL; - } - return (lst); + return lst; } int mutt_check_encoding (const char *c)