2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or (at
5 * your option) any later version.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * Copyright © 2006 Pierre Habouzit
20 #include <lib-lib/ascii.h>
21 #include <lib-lib/url.h>
23 #include "mime-types.h"
27 const char MimeSpecials[] = "@.,;:<>[]\\\"()?/= \t";
29 const char *BodyTypes[] = {
41 const char *BodyEncodings[] = {
51 void envelope_wipe(ENVELOPE *p)
53 address_list_wipe(&p->return_path);
54 address_list_wipe(&p->from);
55 address_list_wipe(&p->to);
56 address_list_wipe(&p->cc);
57 address_list_wipe(&p->bcc);
58 address_list_wipe(&p->sender);
59 address_list_wipe(&p->reply_to);
60 address_list_wipe(&p->mail_followup_to);
62 p_delete(&p->list_post);
63 p_delete(&p->subject);
64 /* real_subj is just an offset to subject and shouldn't be freed */
65 p_delete(&p->message_id);
66 p_delete(&p->supersedes);
68 p_delete(&p->x_label);
69 p_delete(&p->organization);
71 p_delete(&p->newsgroups);
73 p_delete(&p->followup_to);
74 p_delete(&p->x_comment_to);
77 mutt_buffer_free (&p->spam);
78 string_list_wipe(&p->references);
79 string_list_wipe(&p->in_reply_to);
80 string_list_wipe(&p->userhdrs);
83 void header_wipe(HEADER *h)
85 envelope_delete(&h->env);
86 mutt_free_body (&h->content);
87 p_delete(&h->maildir_flags);
91 string_list_wipe(&h->chain);
96 int url_parse_mailto(ENVELOPE *e, char **body, const char *src)
102 char scratch[HUGE_STRING];
106 string_list_t **last = &e->userhdrs;
108 if (!(t = strchr (src, ':')))
111 if ((tmp = m_strdup(t + 1)) == NULL)
114 if ((headers = strchr (tmp, '?')))
118 e->to = rfc822_parse_adrlist (e->to, tmp);
120 tag = headers ? strtok (headers, "&") : NULL;
122 for (; tag; tag = strtok (NULL, "&")) {
123 if ((value = strchr (tag, '=')))
125 if (!value || !*value)
131 if (!ascii_strcasecmp (tag, "body")) {
133 m_strreplace(body, value);
136 #define SAFEPFX (option (OPTSTRICTMAILTO) ? "" : "X-Mailto-")
137 taglen = m_strlen(tag) + m_strlen(SAFEPFX);
138 /* mutt_parse_rfc822_line makes some assumptions */
139 snprintf (scratch, sizeof (scratch), "%s%s: %s", SAFEPFX, tag, value);
141 scratch[taglen] = '\0';
142 value = vskipspaces(&scratch[taglen + 1]);
143 last = mutt_parse_rfc822_line (e, NULL, scratch, value, 0, 0, last);
144 /* if $strict_mailto is set, force editing headers to let
145 * users have a look at what we got */
146 if (!option (OPTSTRICTMAILTO)) {
147 set_option (OPTXMAILTO);
148 set_option (OPTEDITHDRS);