summaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-02-01 15:15:17 -0800
committerKevin McCarthy <kevin@8t8.us>2021-02-01 15:28:01 -0800
commit09f077c9dea38b4b6f76475cd40d2dd1b885b1e6 (patch)
tree5093da610186d39d2406044cf73a3a22e49479e2 /init.c
parent961cf4bed679d9495cc3682d18496a53061d4581 (diff)
Change REPLYTO handling to directly add the my_hdr.
Don't send the header through the muttrc parser, to avoid issues with unexpected evaluation of an environment variable.
Diffstat (limited to 'init.c')
-rw-r--r--init.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/init.c b/init.c
index 63cbdbda..b976cd0d 100644
--- a/init.c
+++ b/init.c
@@ -1716,29 +1716,28 @@ parse_unmy_hdr (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err)
return 0;
}
-static int parse_my_hdr (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err)
+static int update_my_hdr (const char *my_hdr)
{
LIST *tmp;
size_t keylen;
- char *p;
+ const char *p;
- mutt_extract_token (buf, s, MUTT_TOKEN_SPACE | MUTT_TOKEN_QUOTE);
- if ((p = strpbrk (buf->data, ": \t")) == NULL || *p != ':')
- {
- strfcpy (err->data, _("invalid header field"), err->dsize);
- return (-1);
- }
- keylen = p - buf->data + 1;
+ if (!my_hdr)
+ return -1;
+
+ if ((p = strpbrk (my_hdr, ": \t")) == NULL || *p != ':')
+ return -1;
+ keylen = p - my_hdr + 1;
if (UserHeader)
{
for (tmp = UserHeader; ; tmp = tmp->next)
{
/* see if there is already a field by this name */
- if (ascii_strncasecmp (buf->data, tmp->data, keylen) == 0)
+ if (ascii_strncasecmp (my_hdr, tmp->data, keylen) == 0)
{
/* replace the old value */
- mutt_str_replace (&tmp->data, mutt_b2s (buf));
+ mutt_str_replace (&tmp->data, my_hdr);
return 0;
}
if (!tmp->next)
@@ -1752,7 +1751,20 @@ static int parse_my_hdr (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUF
tmp = mutt_new_list ();
UserHeader = tmp;
}
- tmp->data = safe_strdup (mutt_b2s (buf));
+ tmp->data = safe_strdup (my_hdr);
+
+ return 0;
+}
+
+static int parse_my_hdr (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err)
+{
+ mutt_extract_token (buf, s, MUTT_TOKEN_SPACE | MUTT_TOKEN_QUOTE);
+ if (update_my_hdr (mutt_b2s (buf)))
+ {
+ strfcpy (err->data, _("invalid header field"), err->dsize);
+ return -1;
+ }
+
return 0;
}
@@ -3753,15 +3765,8 @@ void mutt_init (int skip_sys_rc, LIST *commands)
if ((p = getenv ("REPLYTO")) != NULL)
{
- BUFFER *token;
- union pointer_long_t udata = {.l=0};
-
mutt_buffer_printf (buffer, "Reply-To: %s", p);
- mutt_buffer_rewind (buffer);
-
- token = mutt_buffer_pool_get ();
- parse_my_hdr (token, buffer, udata, &err);
- mutt_buffer_pool_release (&token);
+ update_my_hdr (mutt_b2s (buffer));
}
if ((p = getenv ("EMAIL")) != NULL)