/*
- * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ * Copyright (C) 1996-2009 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
struct stat st;
LIST *cur, **last = NULL, *tmp;
- mutt_mktemp (path);
+ mutt_mktemp (path, sizeof (path));
if ((ofp = safe_fopen (path, "w")) == NULL)
{
mutt_perror (path);
mutt_copy_stream (ifp, ofp);
- fclose (ifp);
- fclose (ofp);
+ safe_fclose (&ifp);
+ safe_fclose (&ofp);
if (stat (path, &st) == -1)
{
if ((ofp = safe_fopen (body, "w")) == NULL)
{
/* intentionally leak a possible temporary file here */
- fclose (ifp);
+ safe_fclose (&ifp);
mutt_perror (body);
return;
}
n = mutt_read_rfc822_header (ifp, NULL, 1, 0);
while ((i = fread (buffer, 1, sizeof (buffer), ifp)) > 0)
fwrite (buffer, 1, i, ofp);
- fclose (ofp);
- fclose (ifp);
+ safe_fclose (&ofp);
+ safe_fclose (&ifp);
mutt_unlink (path);
+ /* in case the user modifies/removes the In-Reply-To header with
+ $edit_headers set, we remove References: as they're likely invalid;
+ we can simply compare strings as we don't generate References for
+ multiple Message-Ids in IRT anyways */
+ if (!n->in_reply_to || (msg->env->in_reply_to &&
+ mutt_strcmp (n->in_reply_to->data,
+ msg->env->in_reply_to->data) != 0))
+ mutt_free_list (&msg->env->references);
+
/* restore old info. */
+ mutt_free_list (&n->references);
n->references = msg->env->references;
msg->env->references = NULL;
mutt_free_envelope (&msg->env);
msg->env = n; n = NULL;
- if (!msg->env->in_reply_to)
- mutt_free_list (&msg->env->references);
-
mutt_expand_aliases_env (msg->env);
- /* search through the user defined headers added to see if either a
- * fcc: or attach-file: field was specified.
+ /* search through the user defined headers added to see if
+ * fcc: or attach: or pgp: was specified
*/
cur = msg->env->userhdrs;
{
keep = 1;
- /* keep track of whether or not we see the in-reply-to field. if we did
- * not, remove the references: field later so that we can generate a new
- * message based upon this one.
- */
if (fcc && ascii_strncasecmp ("fcc:", cur->data, 4) == 0)
{
p = cur->data + 4;
if (*p)
{
strfcpy (fcc, p, fcclen);
- mutt_pretty_mailbox (fcc);
+ mutt_pretty_mailbox (fcc, fcclen);
}
keep = 0;
}
{
BODY *body;
BODY *parts;
- char *q;
+ int l = 0;
p = cur->data + 7;
SKIPWS (p);
if (*p)
{
- if ((q = strpbrk (p, " \t")))
+ for ( ; *p && *p != ' ' && *p != '\t'; p++)
{
- mutt_substrcpy (path, p, q, sizeof (path));
- SKIPWS (q);
+ if (*p == '\\')
+ {
+ if (!*(p+1))
+ break;
+ p++;
+ }
+ if (l < sizeof (path) - 1)
+ path[l++] = *p;
}
- else
- strfcpy (path, p, sizeof (path));
+ if (*p)
+ *p++ = 0;
+ SKIPWS (p);
+ path[l] = 0;
+
mutt_expand_path (path, sizeof (path));
if ((body = mutt_make_file_attach (path)))
{
- body->description = safe_strdup (q);
+ body->description = safe_strdup (p);
for (parts = msg->content; parts->next; parts = parts->next) ;
parts->next = body;
}
else
{
- mutt_pretty_mailbox (path);
+ mutt_pretty_mailbox (path, sizeof (path));
mutt_error (_("%s: unable to attach file"), path);
}
}
keep = 0;
}
-
-
else if ((WithCrypto & APPLICATION_PGP)
- &&ascii_strncasecmp ("pgp:", cur->data, 4) == 0)
+ && ascii_strncasecmp ("pgp:", cur->data, 4) == 0)
{
msg->security = mutt_parse_crypt_hdr (cur->data + 4, 0, APPLICATION_PGP);
if (msg->security)