From 46ae61b0263d9f1f5fb9da89f45128f30ce4ccea Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Sat, 30 Mar 2002 08:24:16 +0000 Subject: [PATCH] The attached patch allows the user to override the user-agent field with my_hdr. It also removes the stripping of the x-mailer field when recalling a postponed message. --- postpone.c | 20 +------------------- sendlib.c | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/postpone.c b/postpone.c index 3bcee64d..8276e37f 100644 --- a/postpone.c +++ b/postpone.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1996-2002 Michael R. Elkins * Copyright (C) 1999-2000 Thomas Roessler * * 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? */ diff --git a/sendlib.c b/sendlib.c index 80224681..6b9b2150 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1996-2002 Michael R. Elkins * * 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); } -- 2.40.0