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 rfc1524_entry_wipe(rfc1524_entry *p)
53 p_delete(&p->command);
54 p_delete(&p->testcommand);
55 p_delete(&p->composecommand);
56 p_delete(&p->composetypecommand);
57 p_delete(&p->editcommand);
58 p_delete(&p->printcommand);
59 p_delete(&p->nametemplate);
60 p_delete(&p->convert);
63 void envelope_wipe(ENVELOPE *p)
65 address_list_wipe(&p->return_path);
66 address_list_wipe(&p->from);
67 address_list_wipe(&p->to);
68 address_list_wipe(&p->cc);
69 address_list_wipe(&p->bcc);
70 address_list_wipe(&p->sender);
71 address_list_wipe(&p->reply_to);
72 address_list_wipe(&p->mail_followup_to);
74 p_delete(&p->list_post);
75 p_delete(&p->subject);
76 /* real_subj is just an offset to subject and shouldn't be freed */
77 p_delete(&p->message_id);
78 p_delete(&p->supersedes);
80 p_delete(&p->x_label);
81 p_delete(&p->organization);
83 p_delete(&p->newsgroups);
85 p_delete(&p->followup_to);
86 p_delete(&p->x_comment_to);
89 mutt_buffer_free (&p->spam);
90 string_list_wipe(&p->references);
91 string_list_wipe(&p->in_reply_to);
92 string_list_wipe(&p->userhdrs);
95 void header_wipe(HEADER *h)
97 envelope_delete(&h->env);
98 mutt_free_body (&h->content);
99 p_delete(&h->maildir_flags);
103 string_list_wipe(&h->chain);
108 int url_parse_mailto(ENVELOPE *e, char **body, const char *src)
114 char scratch[HUGE_STRING];
118 string_list_t **last = &e->userhdrs;
120 if (!(t = strchr (src, ':')))
123 if ((tmp = m_strdup(t + 1)) == NULL)
126 if ((headers = strchr (tmp, '?')))
130 e->to = rfc822_parse_adrlist (e->to, tmp);
132 tag = headers ? strtok (headers, "&") : NULL;
134 for (; tag; tag = strtok (NULL, "&")) {
135 if ((value = strchr (tag, '=')))
137 if (!value || !*value)
143 if (!ascii_strcasecmp (tag, "body")) {
145 m_strreplace(body, value);
148 #define SAFEPFX (option (OPTSTRICTMAILTO) ? "" : "X-Mailto-")
149 taglen = m_strlen(tag) + m_strlen(SAFEPFX);
150 /* mutt_parse_rfc822_line makes some assumptions */
151 snprintf (scratch, sizeof (scratch), "%s%s: %s", SAFEPFX, tag, value);
153 scratch[taglen] = '\0';
154 value = vskipspaces(&scratch[taglen + 1]);
155 last = mutt_parse_rfc822_line (e, NULL, scratch, value, 0, 0, last);
156 /* if $strict_mailto is set, force editing headers to let
157 * users have a look at what we got */
158 if (!option (OPTSTRICTMAILTO)) {
159 set_option (OPTXMAILTO);
160 set_option (OPTEDITHDRS);