me
diff -r 2cd62f40d840 hcache.c --- a/hcache.c Sun Apr 11 20:00:38 2010 -0700 +++ b/hcache.c Mon Apr 12 14:16:21 2010 -0700 @@ -481,6 +481,9 @@ restore_list(&e->references, d, off, 0); restore_list(&e->in_reply_to, d, off, 0); restore_list(&e->userhdrs, d, off, convert); + + if (e->list_post) + mutt_auto_subscribe(e->list_post); } static int diff -r 2cd62f40d840 init.c --- a/init.c Sun Apr 11 20:00:38 2010 -0700 +++ b/init.c Mon Apr 12 14:16:21 2010 -0700 @@ -413,16 +413,10 @@ if (!s || !*s) return 0; - if (!(rx = mutt_compile_regexp (s, flags))) - { - snprintf (err->data, err->dsize, "Bad regexp: %s\n", s); - return -1; - } - /* check to make sure the item is not already on this list */ for (last = *list; last; last = last->next) { - if (ascii_strcasecmp (rx->pattern, last->rx->pattern) == 0) + if (ascii_strcasecmp (s, last->rx->pattern) == 0) { /* already on the list, so just ignore it */ last = NULL; @@ -434,6 +428,13 @@ if (!*list || last) { + /* delay compilation until after dupe check to improve performance. */ + if (!(rx = mutt_compile_regexp (s, flags))) + { + snprintf (err->data, err->dsize, "Bad regexp: %s\n", s); + return -1; + } + t = mutt_new_rx_list(); t->rx = rx; if (last) @@ -444,8 +445,6 @@ else *list = last = t; } - else /* duplicate */ - mutt_free_regexp (&rx); return 0; } diff -r 2cd62f40d840 parse.c --- a/parse.c Sun Apr 11 20:00:38 2010 -0700 +++ b/parse.c Mon Apr 12 14:16:21 2010 -0700 @@ -966,6 +966,40 @@ cur->attach_valid = 0; } +/* The presence of the List-Post header field indicates the user is + * subscribed to this list. Unless the list is explicitly on the + * unlists or unsubscribe list or it matches the current subscribe + * list, automatically add it to the subscribed lists. + * + * The Subscribed list is checked first since users will often + * filter mail from a list into a separate folder, so we want to + * short-circuit the other checks as quickly as possible. + */ +void mutt_auto_subscribe(const char *mailto) +{ + ENVELOPE *lpenv = mutt_new_envelope(); /* parsed envelope from the List-Post mailto: URL */ + + if ((url_parse_mailto(lpenv, NULL, mailto) != -1) && + lpenv->to && lpenv->to->mailbox && + !mutt_match_rx_list(lpenv->to->mailbox, SubscribedLists) && + !mutt_match_rx_list(lpenv->to->mailbox, UnMailLists) && + !mutt_match_rx_list(lpenv->to->mailbox, UnSubscribedLists)) + { + BUFFER err; + char errbuf[STRING]; + + memset(&err, 0, sizeof(err)); + err.data = errbuf; + err.dsize = sizeof(errbuf); + + /* mutt_add_to_rx_list() detects duplicates, so it is safe to + * try to add here without any checks. */ + mutt_add_to_rx_list(&MailLists, lpenv->to->mailbox, REG_ICASE, &err); + mutt_add_to_rx_list(&SubscribedLists, lpenv->to->mailbox, REG_ICASE, &err); + } + mutt_free_envelope(&lpenv); +} + int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short user_hdrs, short weed, short do_2047, LIST **lastp) { @@ -1110,6 +1144,7 @@ { FREE (&e->list_post); e->list_post = mutt_substrdup (beg, end); + mutt_auto_subscribe(e->list_post); break; } } diff -r 2cd62f40d840 protos.h --- a/protos.h Sun Apr 11 20:00:38 2010 -0700 +++ b/protos.h Mon Apr 12 14:16:21 2010 -0700 @@ -162,6 +162,7 @@ void mutt_alias_menu (char *, size_t, ALIAS *); void mutt_allow_interrupt (int); void mutt_attach_init (BODY *); +void mutt_auto_subscribe (const char *); void mutt_block_signals (void); void mutt_block_signals_system (void); int mutt_body_handler (BODY *, STATE *); diff -r 2cd62f40d840 url.c --- a/url.c Sun Apr 11 20:00:38 2010 -0700 +++ b/url.c Mon Apr 12 14:16:21 2010 -0700 @@ -303,6 +303,7 @@ goto out; } } + rc = 0; out: FREE (&tmp);
pgptSzuVFrVGF.pgp
Description: PGP signature