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 /****************************************************************************/
52 /* rfc822 header parameters */
53 /****************************************************************************/
55 char *parameter_getval(PARAMETER *parm, const char *s)
58 if (!ascii_strcasecmp(parm->attribute, s))
65 /****************************************************************************/
67 /****************************************************************************/
69 void rfc1524_entry_wipe(rfc1524_entry *p)
71 p_delete(&p->command);
72 p_delete(&p->testcommand);
73 p_delete(&p->composecommand);
74 p_delete(&p->composetypecommand);
75 p_delete(&p->editcommand);
76 p_delete(&p->printcommand);
77 p_delete(&p->nametemplate);
78 p_delete(&p->convert);
81 void envelope_wipe(ENVELOPE *p)
83 address_list_wipe(&p->return_path);
84 address_list_wipe(&p->from);
85 address_list_wipe(&p->to);
86 address_list_wipe(&p->cc);
87 address_list_wipe(&p->bcc);
88 address_list_wipe(&p->sender);
89 address_list_wipe(&p->reply_to);
90 address_list_wipe(&p->mail_followup_to);
92 p_delete(&p->list_post);
93 p_delete(&p->subject);
94 /* real_subj is just an offset to subject and shouldn't be freed */
95 p_delete(&p->message_id);
96 p_delete(&p->supersedes);
98 p_delete(&p->x_label);
99 p_delete(&p->organization);
101 p_delete(&p->newsgroups);
103 p_delete(&p->followup_to);
104 p_delete(&p->x_comment_to);
107 mutt_buffer_free (&p->spam);
108 string_list_wipe(&p->references);
109 string_list_wipe(&p->in_reply_to);
110 string_list_wipe(&p->userhdrs);
113 void header_wipe(HEADER *h)
115 envelope_delete(&h->env);
116 mutt_free_body (&h->content);
117 p_delete(&h->maildir_flags);
121 string_list_wipe(&h->chain);
126 int url_parse_mailto(ENVELOPE *e, char **body, const char *src)
132 char scratch[HUGE_STRING];
136 string_list_t **last = &e->userhdrs;
138 if (!(t = strchr (src, ':')))
141 if ((tmp = m_strdup(t + 1)) == NULL)
144 if ((headers = strchr (tmp, '?')))
148 e->to = rfc822_parse_adrlist (e->to, tmp);
150 tag = headers ? strtok (headers, "&") : NULL;
152 for (; tag; tag = strtok (NULL, "&")) {
153 if ((value = strchr (tag, '=')))
155 if (!value || !*value)
161 if (!ascii_strcasecmp (tag, "body")) {
163 m_strreplace(body, value);
166 #define SAFEPFX (option (OPTSTRICTMAILTO) ? "" : "X-Mailto-")
167 taglen = m_strlen(tag) + m_strlen(SAFEPFX);
168 /* mutt_parse_rfc822_line makes some assumptions */
169 snprintf (scratch, sizeof (scratch), "%s%s: %s", SAFEPFX, tag, value);
171 scratch[taglen] = '\0';
172 value = vskipspaces(&scratch[taglen + 1]);
173 last = mutt_parse_rfc822_line (e, NULL, scratch, value, 0, 0, last);
174 /* if $strict_mailto is set, force editing headers to let
175 * users have a look at what we got */
176 if (!option (OPTSTRICTMAILTO)) {
177 set_option (OPTXMAILTO);
178 set_option (OPTEDITHDRS);