#include "remailer.h"
+int url_parse_mailto(ENVELOPE *e, char **body, const char *src)
+{
+ char *t;
+ char *tmp;
+ char *headers;
+ char *tag, *value;
+ char scratch[HUGE_STRING];
+
+ int taglen;
+
+ string_list_t **last = &e->userhdrs;
+
+ if (!(t = strchr (src, ':')))
+ return -1;
+
+ if ((tmp = m_strdup(t + 1)) == NULL)
+ return -1;
+
+ if ((headers = strchr (tmp, '?')))
+ *headers++ = '\0';
+
+ url_decode(tmp);
+ e->to = rfc822_parse_adrlist(e->to, tmp);
+
+ tag = headers ? strtok (headers, "&") : NULL;
+
+ for (; tag; tag = strtok(NULL, "&")) {
+ if ((value = strchr (tag, '=')))
+ *value++ = '\0';
+ if (!value || !*value)
+ continue;
+
+ url_decode (tag);
+ url_decode (value);
+
+ if (mime_which_token(tag, -1) == MIME_BODY) {
+ if (body)
+ m_strreplace(body, value);
+ } else {
+#define SAFEPFX (option(OPTSTRICTMAILTO) ? "" : "X-Mailto-")
+ taglen = m_strlen(tag) + strlen(SAFEPFX);
+ /* mutt_parse_rfc822_line makes some assumptions */
+ snprintf(scratch, sizeof(scratch), "%s%s: %s", SAFEPFX, tag, value);
+#undef SAVEPFX
+ scratch[taglen] = '\0';
+ value = vskipspaces(&scratch[taglen + 1]);
+ last = mutt_parse_rfc822_line (e, NULL, scratch, value, 0, 0, last);
+ /* if $strict_mailto is set, force editing headers to let
+ * users have a look at what we got */
+ if (!option (OPTSTRICTMAILTO)) {
+ set_option (OPTXMAILTO);
+ set_option (OPTEDITHDRS);
+ }
+ }
+ }
+
+ p_delete(&tmp);
+ return 0;
+}
static void append_signature (FILE * f)
{
FILE *tmpfp;
do {
buf[0] = 0;
mutt_addrlist_to_local (*a);
- rfc822_write_address (buf, sizeof (buf), *a, 0);
+ rfc822_addrcat(buf, sizeof(buf), *a, 0);
if (mutt_get_field (field, buf, sizeof (buf), M_ALIAS) != 0)
return (-1);
address_list_wipe(a);
static void process_user_recips (ENVELOPE * env)
{
- string_list_t *uh = UserHeader;
+ string_list_t *uh = UserHeader;
- for (; uh; uh = uh->next) {
- if (ascii_strncasecmp ("to:", uh->data, 3) == 0)
- env->to = rfc822_parse_adrlist (env->to, uh->data + 3);
- else if (ascii_strncasecmp ("cc:", uh->data, 3) == 0)
- env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3);
- else if (ascii_strncasecmp ("bcc:", uh->data, 4) == 0)
- env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4);
+ for (; uh; uh = uh->next) {
+ const char *p = strchr(uh->data, ':');
+ if (!p)
+ continue;
+
+ switch (mime_which_token(uh->data, p++ - uh->data)) {
+ case MIME_TO:
+ env->to = rfc822_parse_adrlist(env->to, p);
+ break;
+ case MIME_CC:
+ env->cc = rfc822_parse_adrlist(env->cc, p);
+ break;
+ case MIME_BCC:
+ env->bcc = rfc822_parse_adrlist(env->bcc, p);
+ break;
#ifdef USE_NNTP
- else if (ascii_strncasecmp ("newsgroups:", uh->data, 11) == 0)
- env->newsgroups = nntp_get_header (uh->data + 11);
- else if (ascii_strncasecmp ("followup-to:", uh->data, 12) == 0)
- env->followup_to = nntp_get_header (uh->data + 12);
- else if (ascii_strncasecmp ("x-comment-to:", uh->data, 13) == 0)
- env->x_comment_to = nntp_get_header (uh->data + 13);
+ case MIME_NEWSGROUPS:
+ env->newsgroups = nntp_get_header(p);
+ break;
+ case MIME_FOLLOWUP_TO:
+ env->followup_to = nntp_get_header(p);
+ break;
+ case MIME_X_COMMENT_TO:
+ env->x_comment_to = nntp_get_header(p);
+ break;
#endif
- }
+ default: break;
+ }
+ }
}
-static void process_user_header (ENVELOPE * env)
+static void process_user_header(ENVELOPE * env)
{
- string_list_t *uh = UserHeader;
- string_list_t *last = env->userhdrs;
-
- if (last)
- while (last->next)
- last = last->next;
-
- for (; uh; uh = uh->next) {
- if (ascii_strncasecmp ("from:", uh->data, 5) == 0) {
- /* User has specified a default From: address. Remove default address */
- address_list_wipe(&env->from);
- env->from = rfc822_parse_adrlist (env->from, uh->data + 5);
- }
- else if (ascii_strncasecmp ("reply-to:", uh->data, 9) == 0) {
- address_list_wipe(&env->reply_to);
- env->reply_to = rfc822_parse_adrlist (env->reply_to, uh->data + 9);
- }
- else if (ascii_strncasecmp ("message-id:", uh->data, 11) == 0)
- m_strreplace(&env->message_id, uh->data + 11);
- else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
- ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
- ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
+ string_list_t *uh;
+ string_list_t **last = string_list_last(&env->userhdrs);
+
+ for (uh = UserHeader; uh; uh = uh->next) {
+ const char *p = strchr(uh->data, ':');
+ if (!p)
+ continue;
+
+ switch (mime_which_token(uh->data, p++ - uh->data)) {
+ case MIME_FROM:
+ /* User has specified a default From: address. Remove default address */
+ address_list_wipe(&env->from);
+ env->from = rfc822_parse_adrlist(env->from, p);
+ break;
+
+ case MIME_REPLY_TO:
+ address_list_wipe(&env->reply_to);
+ env->reply_to = rfc822_parse_adrlist (env->reply_to, p);
+ break;
+
+ case MIME_MESSAGE_ID:
+ m_strreplace(&env->message_id, p);
+ break;
+
+ case MIME_TO:
+ case MIME_CC:
+ case MIME_BCC:
#ifdef USE_NNTP
- ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
- ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
- ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
+ case MIME_NEWSGROUPS:
+ case MIME_FOLLOWUP_TO:
+ case MIME_X_COMMENT_TO:
#endif
- ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
- ascii_strncasecmp ("subject:", uh->data, 8) != 0) {
- if (last) {
- last->next = string_item_new();
- last = last->next;
- }
- else
- last = env->userhdrs = string_item_new();
- last->data = m_strdup(uh->data);
+ case MIME_SUPERSEDES:
+ case MIME_SUPERCEDES:
+ case MIME_SUBJECT:
+ break;
+
+ default:
+ *last = string_item_new();
+ (*last)->data = m_strdup(uh->data);
+ last = &(*last)->next;
+ break;
+ }
}
- }
}
void mutt_forward_intro (FILE * fp, HEADER * cur)
fputs ("----- Forwarded message from ", fp);
buffer[0] = 0;
- rfc822_write_address (buffer, sizeof (buffer), cur->env->from, 1);
+ rfc822_addrcat(buffer, sizeof(buffer), cur->env->from, 1);
fputs (buffer, fp);
fputs (" -----\n\n", fp);
}
from field */
static address_t *set_reverse_name (ENVELOPE * env)
{
- address_t *tmp;
+ address_t *tmp = NULL;
for (tmp = env->to; tmp; tmp = tmp->next) {
if (mutt_addr_is_user(tmp))
if (!mutt_addr_is_user(env->from))
return NULL;
+ tmp = env->from;
+
found:
tmp = address_dup(tmp);
if (!option(OPTREVREAL) || !tmp->personal) {
if (From)
adr = address_dup(From);
- else if (option (OPTUSEDOMAIN)) {
+ else if (MCore.use_domain) {
const char *fqdn = mutt_fqdn (1);
adr = address_new();
- adr->mailbox = p_new(char, m_strlen(Username) + m_strlen(fqdn) + 2);
- sprintf(adr->mailbox, "%s@%s", NONULL(Username), NONULL(fqdn));
+ adr->mailbox = p_new(char, m_strlen(MCore.username) + m_strlen(fqdn) + 2);
+ sprintf(adr->mailbox, "%s@%s", NONULL(MCore.username), NONULL(fqdn));
} else {
adr = address_new ();
- adr->mailbox = m_strdup(NONULL(Username));
+ adr->mailbox = m_strdup(NONULL(MCore.username));
}
return (adr);
int i;
/* Write out the message in MIME form. */
- tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+ tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL);
if (!tempfp)
return -1;
if (!tempfile) {
char buffer[_POSIX_PATH_MAX];
- tempfp = m_tempfile(buffer, sizeof(buffer), NONULL(Tempdir), NULL);
+ tempfp = m_tempfile(buffer, sizeof(buffer), NONULL(MCore.tmpdir), NULL);
msg->content->filename = m_strdup(buffer);
} else {
tempfp = safe_fopen(tempfile, "a+");
process_user_header (msg->env);
- if (option (OPTSIGONTOP) && (!(flags & SENDKEY) && Editor))
+ if (option (OPTSIGONTOP) && (!(flags & SENDKEY)))
append_signature (tempfp);
/* include replies/forwarded messages, unless we are given a template */
&& generate_body (tempfp, msg, flags, ctx, cur) == -1)
goto cleanup;
- if (!option (OPTSIGONTOP) && (!(flags & SENDKEY) && Editor))
+ if (!option (OPTSIGONTOP) && (!(flags & SENDKEY)))
append_signature (tempfp);
/*
goto cleanup;
} else if (option (OPTEDITHDRS)) {
mutt_env_to_local (msg->env);
- mutt_edit_headers (Editor, msg->content->filename, msg, fcc,
- sizeof (fcc));
+ mutt_edit_headers(msg->content->filename, msg, fcc, sizeof (fcc));
mutt_env_to_idna (msg->env, NULL, NULL);
}
else {
- mutt_edit_file (Editor, msg->content->filename);
+ mutt_edit_file(msg->content->filename);
if (stat (msg->content->filename, &st) == 0) {
if (mtime != st.st_mtime)