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 address_wipe(address_t *addr)
53 p_delete(&addr->personal);
54 p_delete(&addr->mailbox);
55 address_delete(&addr->next);
58 void parameter_wipe(PARAMETER *param)
60 p_delete(¶m->attribute);
61 p_delete(¶m->value);
62 parameter_delete(¶m->next);
65 void envelope_wipe(ENVELOPE *p)
67 address_delete(&p->return_path);
68 address_delete(&p->from);
69 address_delete(&p->to);
70 address_delete(&p->cc);
71 address_delete(&p->bcc);
72 address_delete(&p->sender);
73 address_delete(&p->reply_to);
74 address_delete(&p->mail_followup_to);
76 p_delete(&p->list_post);
77 p_delete(&p->subject);
78 /* real_subj is just an offset to subject and shouldn't be freed */
79 p_delete(&p->message_id);
80 p_delete(&p->supersedes);
82 p_delete(&p->x_label);
83 p_delete(&p->organization);
85 p_delete(&p->newsgroups);
87 p_delete(&p->followup_to);
88 p_delete(&p->x_comment_to);
91 mutt_buffer_free (&p->spam);
92 mutt_free_list(&p->references);
93 mutt_free_list(&p->in_reply_to);
94 mutt_free_list(&p->userhdrs);
97 void header_wipe(HEADER *h)
99 envelope_delete(&h->env);
100 mutt_free_body (&h->content);
101 p_delete(&h->maildir_flags);
105 mutt_free_list(&h->chain);
110 int url_parse_mailto(ENVELOPE *e, char **body, const char *src)
116 char scratch[HUGE_STRING];
120 LIST **last = &e->userhdrs;
122 if (!(t = strchr (src, ':')))
125 if ((tmp = m_strdup(t + 1)) == NULL)
128 if ((headers = strchr (tmp, '?')))
132 e->to = rfc822_parse_adrlist (e->to, tmp);
134 tag = headers ? strtok (headers, "&") : NULL;
136 for (; tag; tag = strtok (NULL, "&")) {
137 if ((value = strchr (tag, '=')))
139 if (!value || !*value)
145 if (!ascii_strcasecmp (tag, "body")) {
147 m_strreplace(body, value);
150 #define SAFEPFX (option (OPTSTRICTMAILTO) ? "" : "X-Mailto-")
151 taglen = m_strlen(tag) + m_strlen(SAFEPFX);
152 /* mutt_parse_rfc822_line makes some assumptions */
153 snprintf (scratch, sizeof (scratch), "%s%s: %s", SAFEPFX, tag, value);
155 scratch[taglen] = '\0';
156 value = vskipspaces(&scratch[taglen + 1]);
157 last = mutt_parse_rfc822_line (e, NULL, scratch, value, 0, 0, last);
158 /* if $strict_mailto is set, force editing headers to let
159 * users have a look at what we got */
160 if (!option (OPTSTRICTMAILTO)) {
161 set_option (OPTXMAILTO);
162 set_option (OPTEDITHDRS);