]> granicus.if.org Git - mutt/commitdiff
The attached patch allows the user to override the user-agent field
authorThomas Roessler <roessler@does-not-exist.org>
Sat, 30 Mar 2002 08:24:16 +0000 (08:24 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Sat, 30 Mar 2002 08:24:16 +0000 (08:24 +0000)
with my_hdr.  It also removes the stripping of the x-mailer field
when recalling a postponed message.

postpone.c
sendlib.c

index 3bcee64d5b249b0e7d3800326baab4ead21a187c..8276e37fc6c605ef9aa89a55742909d7cc5ea81d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
+ * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
  * Copyright (C) 1999-2000 Thomas Roessler <roessler@guug.de>
  * 
  *     This program is free software; you can redistribute it and/or modify
@@ -543,24 +543,6 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
   newhdr->content->length = hdr->content->length;
   mutt_parse_part (fp, newhdr->content);
 
-  /* weed user-agent, x-mailer - we don't want them here */
-  p = newhdr->env->userhdrs; 
-  q = &newhdr->env->userhdrs;
-
-  while (p)
-  {
-    if (!ascii_strncasecmp (p->data, "x-mailer:", 9) || !ascii_strncasecmp (p->data, "user-agent:", 11))
-    {
-      *q = p->next;
-      p->next = NULL;
-      mutt_free_list (&p);
-    }
-    else
-      q = &p->next;
-
-    p = *q;
-  }
-
   safe_free ((void **) &newhdr->env->message_id);
   safe_free ((void **) &newhdr->env->mail_followup_to); /* really? */
 
index 80224681183454e8a2c203ee3224102ac3017507..6b9b2150be068af4862912586bee13bdf98aa702 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
+ * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
  * 
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -1605,6 +1605,7 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
   char buffer[LONG_STRING];
   char *p;
   LIST *tmp = env->userhdrs;
+  int has_agent = 0; /* user defined user-agent header field exists */
   
   if (mode == 0 && !privacy)
     fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
@@ -1690,12 +1691,6 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
     fputc ('\n', fp);
   }
   
-  if (mode == 0 && !privacy && option (OPTXMAILER))
-  {
-    /* Add a vanity header */
-    fprintf (fp, "User-Agent: Mutt/%s\n", MUTT_VERSION);
-  }
-
   /* Add any user defined headers */
   for (; tmp; tmp = tmp->next)
   {
@@ -1704,11 +1699,25 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
       p++; SKIPWS (p);
       if (!*p)         continue;  /* don't emit empty fields. */
 
+      /* check to see if the user has overridden the user-agent field */
+      if (!ascii_strncasecmp ("user-agent", tmp->data, 10))
+      {
+       has_agent = 1;
+       if (privacy)
+         continue;
+      }
+
       fputs (tmp->data, fp);
       fputc ('\n', fp);
     }
   }
 
+  if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent)
+  {
+    /* Add a vanity header */
+    fprintf (fp, "User-Agent: Mutt/%s\n", MUTT_VERSION);
+  }
+
   return (ferror (fp) == 0 ? 0 : -1);
 }