X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..fc83c7648c73765a72c74175b6952a0fda80dd00:/rfc822.c?ds=inline diff --git a/rfc822.c b/rfc822.c index 4500e67..3a04bd4 100644 --- a/rfc822.c +++ b/rfc822.c @@ -33,7 +33,7 @@ #define FREE(x) safe_free(x) #define ISSPACE isspace #define strfcpy(a,b,c) {if (c) {strncpy(a,b,c);a[c-1]=0;}} -#define STRING 128 +#define LONG_STRING 1024 #include "rfc822.h" #endif @@ -60,7 +60,7 @@ const char *RFC822Errors[] = { "bad address spec" }; -void rfc822_dequote_comment (char *s) +static void rfc822_dequote_comment (char *s) { char *w = s; @@ -256,7 +256,7 @@ parse_route_addr (const char *s, char *comment, size_t *commentlen, size_t commentmax, ADDRESS *addr) { - char token[STRING]; + char token[LONG_STRING]; size_t tokenlen = 0; SKIPWS (s); @@ -304,7 +304,7 @@ parse_addr_spec (const char *s, char *comment, size_t *commentlen, size_t commentmax, ADDRESS *addr) { - char token[STRING]; + char token[LONG_STRING]; size_t tokenlen = 0; s = parse_address (s, token, &tokenlen, sizeof (token) - 1, comment, commentlen, commentmax, addr); @@ -339,7 +339,7 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s) { int ws_pending, nl; const char *begin, *ps; - char comment[STRING], phrase[STRING]; + char comment[LONG_STRING], phrase[LONG_STRING]; size_t phraselen = 0, commentlen = 0; ADDRESS *cur, *last = NULL; @@ -594,8 +594,6 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS *addr, { if (*pc == '"' || *pc == '\\') { - if (!buflen) - goto done; *pbuf++ = '\\'; buflen--; } @@ -759,12 +757,17 @@ ADDRESS *rfc822_cpy_adr_real (ADDRESS *addr) } /* this should be rfc822_cpy_adrlist */ -ADDRESS *rfc822_cpy_adr (ADDRESS *addr) +ADDRESS *rfc822_cpy_adr (ADDRESS *addr, int prune) { ADDRESS *top = NULL, *last = NULL; for (; addr; addr = addr->next) { + if (prune && addr->group && (!addr->next || !addr->next->mailbox)) + { + addr = addr->next; + continue; + } if (last) { last->next = rfc822_cpy_adr_real (addr); @@ -777,7 +780,7 @@ ADDRESS *rfc822_cpy_adr (ADDRESS *addr) } /* append list 'b' to list 'a' and return the last element in the new list */ -ADDRESS *rfc822_append (ADDRESS **a, ADDRESS *b) +ADDRESS *rfc822_append (ADDRESS **a, ADDRESS *b, int prune) { ADDRESS *tmp = *a; @@ -786,9 +789,9 @@ ADDRESS *rfc822_append (ADDRESS **a, ADDRESS *b) if (!b) return tmp; if (tmp) - tmp->next = rfc822_cpy_adr (b); + tmp->next = rfc822_cpy_adr (b, prune); else - tmp = *a = rfc822_cpy_adr (b); + tmp = *a = rfc822_cpy_adr (b, prune); while (tmp && tmp->next) tmp = tmp->next; return tmp; @@ -818,7 +821,6 @@ int rfc822_valid_msgid (const char *msgid) * domain-literal = "[" *(dtext / quoted-pair) "]" */ - char* dom; unsigned int l, i; if (!msgid || !*msgid) @@ -829,7 +831,7 @@ int rfc822_valid_msgid (const char *msgid) return -1; if (msgid[0] != '<' || msgid[l-1] != '>') return -1; - if (!(dom = strrchr (msgid, '@'))) + if (!(strrchr (msgid, '@'))) return -1; /* TODO: complete parser */