On 2004-07-18 20:06:51 +0200, Hugo Haas wrote: > Thanks. Attached is v3 which is v2 plus LIST-POST added to > want_headers. Here's an alternative approach which reuses the existing mailto URL parsing code. Thoughts? -- Thomas Roessler · Personal soap box at <http://log.does-not-exist.org/>.
Index: mutt.h =================================================================== RCS file: /cvs/mutt/mutt/mutt.h,v retrieving revision 3.33 diff -u -r3.33 mutt.h --- mutt.h 15 Jul 2004 08:08:32 -0000 3.33 +++ mutt.h 19 Jul 2004 22:35:29 -0000 @@ -567,6 +567,7 @@ ADDRESS *sender; ADDRESS *reply_to; ADDRESS *mail_followup_to; + char *list_post; /* this stores a mailto URL, or nothing */ char *subject; char *real_subj; /* offset of the real subject */ char *message_id; Index: parse.c =================================================================== RCS file: /cvs/mutt/mutt/parse.c,v retrieving revision 3.12 diff -u -r3.12 parse.c --- parse.c 14 Jul 2004 04:16:58 -0000 3.12 +++ parse.c 19 Jul 2004 22:35:30 -0000 @@ -23,6 +23,7 @@ #include "rfc2047.h" #include "rfc2231.h" #include "mutt_crypt.h" +#include "url.h" #include <string.h> #include <ctype.h> @@ -1064,6 +1065,29 @@ hdr->lines = 0; } + matched = 1; + } + else if (!ascii_strcasecmp (line + 1, "ist-Post")) + { + /* RFC 2369. FIXME: We should ignore whitespace, but don't. */ + if (strncmp (p, "NO", 2)) + { + char *beg, *end; + for (beg = strchr (p, '<'); beg; beg = strchr (end, ',')) + { + ++beg; + if (!(end = strchr (beg, '>'))) + break; + + /* Take the first mailto URL */ + if (url_check_scheme (beg) == U_MAILTO) + { + FREE (&e->list_post); + e->list_post = mutt_substrdup (beg, end); + break; + } + } + } matched = 1; } break; Index: send.c =================================================================== RCS file: /cvs/mutt/mutt/send.c,v retrieving revision 3.33 diff -u -r3.33 send.c --- send.c 14 Jul 2004 04:36:27 -0000 3.33 +++ send.c 19 Jul 2004 22:35:31 -0000 @@ -26,6 +26,7 @@ #include "mx.h" #include "mutt_crypt.h" #include "mutt_idna.h" +#include "url.h" #include <ctype.h> #include <stdlib.h> @@ -592,20 +593,23 @@ /* set the default subject for the message. */ mutt_make_string (buffer, sizeof (buffer), NONULL(ForwFmt), ctx, cur); - env->subject = safe_strdup (buffer); + mutt_str_replace (&env->subject, buffer); } void mutt_make_misc_reply_headers (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, ENVELOPE *curenv) { + /* This takes precedence over a subject that might have + * been taken from a List-Post header. Is that correct? + */ if (curenv->real_subj) { + FREE (&env->subject); env->subject = safe_malloc (mutt_strlen (curenv->real_subj) + 5); sprintf (env->subject, "Re: %s", curenv->real_subj); /* __SPRINTF_CHECKED__ */ } - else + else if (!env->subject) env->subject = safe_strdup ("Re: your mail"); - } void mutt_add_to_reference_headers (ENVELOPE *env, ENVELOPE *curenv, LIST ***pp, LIST ***qq) @@ -1098,6 +1102,16 @@ msg->env = mutt_new_envelope (); } + /* Parse and use an eventual list-post header */ + if ((flags & SENDLISTREPLY) + && cur && cur->env && cur->env->list_post) + { + /* Use any list-post header as a template */ + url_parse_mailto (msg->env, NULL, cur->env->list_post); + /* We don't let them set the sender's address. */ + rfc822_free_address (&msg->env->from); + } + if (! (flags & (SENDKEY | SENDPOSTPONED | SENDRESEND))) { pbody = mutt_new_body (); Index: url.c =================================================================== RCS file: /cvs/mutt/mutt/url.c,v retrieving revision 3.4 diff -u -r3.4 url.c --- url.c 24 Jul 2003 18:40:50 -0000 3.4 +++ url.c 19 Jul 2004 22:35:31 -0000 @@ -235,7 +235,10 @@ url_pct_decode (value); if (!ascii_strcasecmp (tag, "body")) - mutt_str_replace (body, value); + { + if (body) + mutt_str_replace (body, value); + } else { taglen = strlen (tag); Index: imap/message.c =================================================================== RCS file: /cvs/mutt/mutt/imap/message.c,v retrieving revision 3.7 diff -u -r3.7 message.c --- imap/message.c 19 Jul 2004 21:44:23 -0000 3.7 +++ imap/message.c 19 Jul 2004 22:35:31 -0000 @@ -55,7 +55,7 @@ IMAP_HEADER h; int rc, mfhrc, oldmsgcount; int fetchlast = 0; - const char *want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES X-LABEL"; + const char *want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL"; ctx = idata->ctx;
Attachment:
pgpHJo0rjhyCo.pgp
Description: PGP signature