mutt_history.o mutt_logging.o mutt_signal.o mutt_socket.o mutt_thread.o mutt_url.o mutt_window.o mx.o \
pager.o parse.o pattern.o \
postpone.o progress.o query.o recvattach.o recvcmd.o resize.o rfc1524.o \
- rfc2047.o rfc2231.o rfc3676.o safe_asprintf.o score.o send.o \
+ rfc3676.o safe_asprintf.o score.o send.o \
sendlib.o sidebar.o smtp.o sort.o state.o status.o system.o \
terminal.o version.o
# libemail
LIBEMAIL= libemail.a
LIBEMAILOBJS= email/address.o email/attach.o email/body.o email/envelope.o \
- email/from.o email/header.o email/idna.o email/mime.o email/parameter.o email/rfc2047.o email/tags.o email/thread.o email/url.o
+ email/from.o email/email_globals.o email/header.o email/idna.o \
+ email/mime.o email/parameter.o email/rfc2047.o email/rfc2231.o email/tags.o \
+ email/thread.o email/url.o
CLEANFILES+= $(LIBEMAIL) $(LIBEMAILOBJS)
MUTTLIBS+= $(LIBEMAIL)
ALLOBJS+= $(LIBEMAILOBJS)
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/mutt.h"
+#include "email/email.h"
#include "bcache.h"
#include "globals.h"
#include "mutt_account.h"
#include "muttlib.h"
#include "protos.h"
-#include "email/email.h"
/* These Config Variables are only used in bcache.c */
char *MessageCachedir;
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "protos.h"
-#include "rfc2047.h"
#include "sendlib.h"
#include "state.h"
#ifdef USE_NOTMUCH
if (flags & CH_DECODE)
{
if (address_header_decode(&this_one) == 0)
- mutt_rfc2047_decode(&this_one);
+ rfc2047_decode(&this_one);
this_one_len = mutt_str_strlen(this_one);
/* Convert CRLF line endings to LF */
if (flags & CH_DECODE)
{
if (address_header_decode(&this_one) == 0)
- mutt_rfc2047_decode(&this_one);
+ rfc2047_decode(&this_one);
this_one_len = mutt_str_strlen(this_one);
}
* | email/parameter.c | @subpage email_parameter |
* | email/mime.c | @subpage email_mime |
* | email/rfc2047.c | @subpage email_rfc2047 |
+ * | email/rfc2231.c | @subpage email_rfc2231 |
* | email/tags.c | @subpage email_tags |
* | email/thread.c | @subpage email_thread |
* | email/url.c | @subpage email_url |
#include "attach.h"
#include "body.h"
#include "content.h"
+#include "email_globals.h"
#include "envelope.h"
#include "from.h"
#include "header.h"
#include "mime.h"
#include "parameter.h"
#include "rfc2047.h"
+#include "rfc2231.h"
#include "tags.h"
#include "thread.h"
#include "url.h"
/**
* @file
- * RFC2047 MIME extensions routines
+ * Email Global Variables
*
* @authors
- * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _MUTT_RFC2047_2_H
-#define _MUTT_RFC2047_2_H
-
-struct Address;
-
-void rfc2047_encode_addrlist(struct Address *addr, const char *tag);
-void rfc2047_decode_addrlist(struct Address *a);
+/**
+ * @page email_globals Email Global Variables
+ *
+ * These global variables are private to the email library.
+ */
-#endif /* _MUTT_RFC2047_2_H */
+#include "config.h"
+char *SendCharset;
--- /dev/null
+/**
+ * @file
+ * Email Global Variables
+ *
+ * @authors
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _EMAIL_GLOBALS_H
+#define _EMAIL_GLOBALS_H
+
+extern char *SendCharset;
+
+#endif /* _EMAIL_GLOBALS_H */
#include <regex.h>
#include <stdbool.h>
#include <string.h>
-#include "rfc2047.h"
#include "mutt/mutt.h"
+#include "rfc2047.h"
+#include "address.h"
+#include "email_globals.h"
#include "mime.h"
#define ENCWORD_LEN_MAX 75
}
/**
- * rfc2047_encode - RFC2047-encode a string
+ * rfc2047_encode2 - RFC2047-encode a string
* @param d String to convert
* @param dlen Length of string
* @param col Starting column to convert
* @param specials Special characters to be encoded
* @retval 0 Success
*/
-static int rfc2047_encode(const char *d, size_t dlen, int col, const char *fromcode,
- const char *charsets, char **e, size_t *elen, const char *specials)
+static int rfc2047_encode2(const char *d, size_t dlen, int col,
+ const char *fromcode, const char *charsets, char **e,
+ size_t *elen, const char *specials)
{
int rc = 0;
char *buf = NULL;
}
/**
- * mutt_rfc2047_encode - RFC-2047-encode a string
+ * rfc2047_encode - RFC-2047-encode a string
* @param[in,out] pd String to be encoded, and resulting encoded string
* @param[in] specials Special characters to be encoded
* @param[in] col Starting index in string
* @param[in] charsets List of charsets to choose from
*/
-void mutt_rfc2047_encode(char **pd, const char *specials, int col, const char *charsets)
+void rfc2047_encode(char **pd, const char *specials, int col, const char *charsets)
{
char *e = NULL;
size_t elen;
if (!charsets || !*charsets)
charsets = "utf-8";
- rfc2047_encode(*pd, strlen(*pd), col, Charset, charsets, &e, &elen, specials);
+ rfc2047_encode2(*pd, strlen(*pd), col, Charset, charsets, &e, &elen, specials);
FREE(pd);
*pd = e;
}
/**
- * mutt_rfc2047_decode - Decode any RFC2047-encoded header fields
+ * rfc2047_decode - Decode any RFC2047-encoded header fields
* @param[in,out] pd String to be decoded, and resulting decoded string
*
* Try to decode anything that looks like a valid RFC2047 encoded header field,
* ignoring RFC822 parsing rules. If decoding fails, for example due to an
* invalid base64 string, the original input is left untouched.
*/
-void mutt_rfc2047_decode(char **pd)
+void rfc2047_decode(char **pd)
{
if (!pd || !*pd)
return;
mutt_buffer_addch(&buf, '\0');
*pd = buf.data;
}
+
+/**
+ * rfc2047_encode_addrlist - Encode any RFC2047 headers, where required, in an Address list
+ * @param addr Address list
+ * @param tag Header tag (used for wrapping calculation)
+ */
+void rfc2047_encode_addrlist(struct Address *addr, const char *tag)
+{
+ struct Address *ptr = addr;
+ int col = tag ? strlen(tag) + 2 : 32;
+
+ while (ptr)
+ {
+ if (ptr->personal)
+ rfc2047_encode(&ptr->personal, AddressSpecials, col, SendCharset);
+ else if (ptr->group && ptr->mailbox)
+ rfc2047_encode(&ptr->mailbox, AddressSpecials, col, SendCharset);
+ ptr = ptr->next;
+ }
+}
+
+/**
+ * rfc2047_decode_addrlist - Decode any RFC2047 headers in an Address list
+ * @param a Address list
+ */
+void rfc2047_decode_addrlist(struct Address *a)
+{
+ while (a)
+ {
+ if (a->personal &&
+ ((strstr(a->personal, "=?") != NULL) || (AssumedCharset && *AssumedCharset)))
+ {
+ rfc2047_decode(&a->personal);
+ }
+ else if (a->group && a->mailbox && (strstr(a->mailbox, "=?") != NULL))
+ rfc2047_decode(&a->mailbox);
+ a = a->next;
+ }
+}
#ifndef _EMAIL_RFC2047_H
#define _EMAIL_RFC2047_H
-void mutt_rfc2047_decode(char **pd);
-void mutt_rfc2047_encode(char **pd, const char *specials, int col, const char *charsets);
+struct Address;
+
+void rfc2047_decode(char **pd);
+void rfc2047_encode(char **pd, const char *specials, int col, const char *charsets);
+
+void rfc2047_decode_addrlist(struct Address *a);
+void rfc2047_encode_addrlist(struct Address *addr, const char *tag);
#endif /* _EMAIL_RFC2047_H */
*/
if (Rfc2047Parameters && np->value && strstr(np->value, "=?"))
- mutt_rfc2047_decode(&np->value);
+ rfc2047_decode(&np->value);
else if (AssumedCharset && *AssumedCharset)
mutt_ch_convert_nonmime_string(&np->value);
}
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _MUTT_RFC2231_H
-#define _MUTT_RFC2231_H
+#ifndef _EMAIL_RFC2231_H
+#define _EMAIL_RFC2231_H
struct ParameterList;
void rfc2231_decode_parameters(struct ParameterList *p);
int rfc2231_encode_string(char **pd);
-#endif /* _MUTT_RFC2231_H */
+#endif /* _EMAIL_RFC2231_H */
WHERE char *PrintCommand;
WHERE char *NewMailCommand;
WHERE char *Realname;
-WHERE char *SendCharset;
WHERE char *Shell;
WHERE char *SimpleSearch;
#ifdef USE_SMTP
#include "recvcmd.h"
#include "remailer.h"
#include "rfc1524.h"
-#include "rfc2231.h"
#include "rfc3676.h"
#include "score.h"
#include "send.h"
#include "email/email.h"
#include "mutt.h"
#include "globals.h"
-#include "rfc2047.h"
#include "parse.h"
int url_parse_mailto(struct Envelope *e, char **body, const char *src)
rfc2047_decode_addrlist(e->mail_followup_to);
rfc2047_decode_addrlist(e->return_path);
rfc2047_decode_addrlist(e->sender);
- mutt_rfc2047_decode(&e->x_label);
- mutt_rfc2047_decode(&e->subject);
+ rfc2047_decode(&e->x_label);
+ rfc2047_decode(&e->subject);
rc = 0;
#include "options.h"
#include "protos.h"
#include "recvattach.h"
-#include "rfc2047.h"
-#include "rfc2231.h"
struct Context;
else if (mutt_str_strcasecmp("description", line + 8) == 0)
{
mutt_str_replace(&p->description, c);
- mutt_rfc2047_decode(&p->description);
+ rfc2047_decode(&p->description);
}
}
#ifdef SUN_ATTACHMENT
else if (mutt_str_strcasecmp("data-description", line + 6) == 0)
{
mutt_str_replace(&p->description, c);
- mutt_rfc2047_decode(&p->description);
+ rfc2047_decode(&p->description);
}
}
#endif
if (hdr)
{
mutt_str_replace(&hdr->content->description, p);
- mutt_rfc2047_decode(&hdr->content->description);
+ rfc2047_decode(&hdr->content->description);
}
matched = 1;
}
{
struct ListNode *np = mutt_list_insert_tail(&e->userhdrs, mutt_str_strdup(line));
if (do_2047)
- mutt_rfc2047_decode(&np->data);
+ rfc2047_decode(&np->data);
}
}
{
regmatch_t pmatch[1];
- mutt_rfc2047_decode(&e->subject);
+ rfc2047_decode(&e->subject);
if (ReplyRegex && ReplyRegex->regex &&
(regexec(ReplyRegex->regex, e->subject, 1, pmatch, 0) == 0))
+++ /dev/null
-/**
- * @file
- * RFC2047 MIME extensions routines
- *
- * @authors
- * Copyright (C) 1996-2000,2010 Michael R. Elkins <me@mutt.org>
- * Copyright (C) 2000-2002 Edmund Grimley Evans <edmundo@rano.org>
- *
- * @copyright
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 2 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include "mutt/mutt.h"
-#include "email/email.h"
-#include "globals.h"
-
-#include <string.h>
-
-/**
- * rfc2047_encode_addrlist - Encode any RFC2047 headers, where required, in an Address list
- * @param addr Address list
- * @param tag Header tag (used for wrapping calculation)
- */
-void rfc2047_encode_addrlist(struct Address *addr, const char *tag)
-{
- struct Address *ptr = addr;
- int col = tag ? strlen(tag) + 2 : 32;
-
- while (ptr)
- {
- if (ptr->personal)
- mutt_rfc2047_encode(&ptr->personal, AddressSpecials, col, SendCharset);
- else if (ptr->group && ptr->mailbox)
- mutt_rfc2047_encode(&ptr->mailbox, AddressSpecials, col, SendCharset);
- ptr = ptr->next;
- }
-}
-
-/**
- * rfc2047_decode_addrlist - Decode any RFC2047 headers in an Address list
- * @param a Address list
- */
-void rfc2047_decode_addrlist(struct Address *a)
-{
- while (a)
- {
- if (a->personal &&
- ((strstr(a->personal, "=?") != NULL) || (AssumedCharset && *AssumedCharset)))
- {
- mutt_rfc2047_decode(&a->personal);
- }
- else if (a->group && a->mailbox && (strstr(a->mailbox, "=?") != NULL))
- mutt_rfc2047_decode(&a->mailbox);
- a = a->next;
- }
-}
{
if (t->description)
{
- mutt_rfc2047_encode(&t->description, NULL, sizeof("Content-Description:"), SendCharset);
+ rfc2047_encode(&t->description, NULL, sizeof("Content-Description:"), SendCharset);
}
if (recurse && t->parts)
mutt_encode_descriptions(t->parts, recurse);
{
if (t->description)
{
- mutt_rfc2047_decode(&t->description);
+ rfc2047_decode(&t->description);
}
if (t->parts)
decode_descriptions(t->parts);
#include "parse.h"
#include "protos.h"
#include "recvattach.h"
-#include "rfc2047.h"
-#include "rfc2231.h"
#include "send.h"
#include "smtp.h"
#include "state.h"
if (!tmp)
continue;
- mutt_rfc2047_encode(&tmp, NULL, i + 2, SendCharset);
+ rfc2047_encode(&tmp, NULL, i + 2, SendCharset);
mutt_mem_realloc(&np->data, i + 2 + mutt_str_strlen(tmp) + 1);
sprintf(np->data + i + 2, "%s", tmp);
if (!OptNewsSend || MimeSubject)
#endif
{
- mutt_rfc2047_encode(&env->subject, NULL, sizeof("Subject:"), SendCharset);
+ rfc2047_encode(&env->subject, NULL, sizeof("Subject:"), SendCharset);
}
encode_headers(&env->userhdrs);
}
struct ListNode *item = NULL;
STAILQ_FOREACH(item, &env->userhdrs, entries)
{
- mutt_rfc2047_decode(&item->data);
+ rfc2047_decode(&item->data);
}
mutt_addr_free(&env->mail_followup_to);
rfc2047_decode_addrlist(env->bcc);
rfc2047_decode_addrlist(env->from);
rfc2047_decode_addrlist(env->reply_to);
- mutt_rfc2047_decode(&env->subject);
+ rfc2047_decode(&env->subject);
}
static int bounce_message(FILE *fp, struct Header *h, struct Address *to,
{
/* decode the original string */
char *s = mutt_str_strdup(test_data[i].original);
- mutt_rfc2047_decode(&s);
+ rfc2047_decode(&s);
if (!TEST_CHECK(strcmp(s, test_data[i].decoded) == 0))
{
TEST_MSG("Iteration: %zu", i);
/* encode the expected result */
s = mutt_str_strdup(test_data[i].decoded);
- mutt_rfc2047_encode(&s, NULL, 0, "utf-8");
+ rfc2047_encode(&s, NULL, 0, "utf-8");
if (!TEST_CHECK(strcmp(s, test_data[i].encoded) == 0))
{
TEST_MSG("Iteration: %zu", i);
/* decode the encoded result */
s = mutt_str_strdup(test_data[i].encoded);
- mutt_rfc2047_decode(&s);
+ rfc2047_decode(&s);
if (!TEST_CHECK(strcmp(s, test_data[i].decoded) == 0))
{
TEST_MSG("Iteration: %zu", i);