]> granicus.if.org Git - mutt/commitdiff
Use List-Post headers when doing list-reply.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 20 Jul 2004 08:17:21 +0000 (08:17 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 20 Jul 2004 08:17:21 +0000 (08:17 +0000)
imap/message.c
mutt.h
parse.c
send.c
url.c

index 5d302592604e218a444758debb05854509d10489..aae35acd492f6edd6cd295518ce247c72d947c8a 100644 (file)
@@ -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 e26865edb9a09b48f585a69a4107fe4df0db34a5..97cc66d46c98a349881c9babcd003670af853395 100644 (file)
--- 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 53ecbfda1ad7bb9fa362b6cc348232b9e013758c..c9731f735ae8895e116147f011086c6069fb061b 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -23,6 +23,7 @@
 #include "rfc2047.h"
 #include "rfc2231.h"
 #include "mutt_crypt.h"
+#include "url.h"
 
 #include <string.h>
 #include <ctype.h>
@@ -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 1d791934e84ba077b290d6648c6f320663f9bb97..7fb9b5e6cf2602738fc91fbee4f68faf97b57a93 100644 (file)
--- 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 <ctype.h>
 #include <stdlib.h>
@@ -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 ae2a22dfa02a25f80b920d02f9941803cab990bf..5be09dbe8985014e33106a24f8348d4f6ee5d92b 100644 (file)
--- 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);