From: Thomas Roessler Date: Tue, 20 Jul 2004 08:17:21 +0000 (+0000) Subject: Use List-Post headers when doing list-reply. X-Git-Tag: mutt-1-5-15-rel~130 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a59230d2c124ba8cd8e1c555d921e150f391280e;p=mutt Use List-Post headers when doing list-reply. --- diff --git a/imap/message.c b/imap/message.c index 5d302592..aae35acd 100644 --- a/imap/message.c +++ b/imap/message.c @@ -55,7 +55,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend) 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; diff --git a/mutt.h b/mutt.h index e26865ed..97cc66d4 100644 --- a/mutt.h +++ b/mutt.h @@ -567,6 +567,7 @@ typedef struct envelope 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; diff --git a/parse.c b/parse.c index 53ecbfda..c9731f73 100644 --- a/parse.c +++ b/parse.c @@ -23,6 +23,7 @@ #include "rfc2047.h" #include "rfc2231.h" #include "mutt_crypt.h" +#include "url.h" #include #include @@ -1066,6 +1067,29 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short 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; case 'm': diff --git a/send.c b/send.c index 1d791934..7fb9b5e6 100644 --- a/send.c +++ b/send.c @@ -26,6 +26,7 @@ #include "mx.h" #include "mutt_crypt.h" #include "mutt_idna.h" +#include "url.h" #include #include @@ -592,20 +593,23 @@ void mutt_make_forward_subject (ENVELOPE *env, CONTEXT *ctx, HEADER *cur) /* 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 @@ ci_send_message (int flags, /* send mode */ 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 (); diff --git a/url.c b/url.c index ae2a22df..5be09dbe 100644 --- a/url.c +++ b/url.c @@ -235,7 +235,10 @@ int url_parse_mailto (ENVELOPE *e, char **body, const char *src) 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);