X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc2231.c;h=da505107d6ff84301b338adf8c1a6724f63e5d69;hp=3f194066025a5d8884592f7b59b43f136f3708c4;hb=80566f6aedda1e4bdcca38f9cb27101b5ba1029f;hpb=c660c8cbae7f647c637502779862e4a36ad6a074 diff --git a/lib-mime/rfc2231.c b/lib-mime/rfc2231.c index 3f19406..da50510 100644 --- a/lib-mime/rfc2231.c +++ b/lib-mime/rfc2231.c @@ -36,18 +36,12 @@ * */ -#include -#include -#include - -#include -#include -#include +#include #include #include "charset.h" -#include "rfc2047.h" +#include "mutt.h" typedef struct rfc2231_param { struct rfc2231_param *next; @@ -134,15 +128,14 @@ rfc2231_list_insert(rfc2231_param **list, rfc2231_param *par) *list = par; } -static void purge_empty_parameters(PARAMETER **headp) +static void purge_empty_parameters(parameter_t **headp) { while (*headp) { - PARAMETER *p = *headp; + parameter_t *p = *headp; if (!p->attribute || !p->value) { - *headp = p->next; - p->next = NULL; - mutt_free_parameter(&p); + p = parameter_list_pop(headp); + parameter_delete(&p); } else { headp = &(*headp)->next; } @@ -152,7 +145,7 @@ static void purge_empty_parameters(PARAMETER **headp) /* process continuation parameters */ /* XXX: MC: not read */ static void -rfc2231_join_continuations(PARAMETER **head, rfc2231_param *par) +rfc2231_join_continuations(parameter_t **head, rfc2231_param *par) { rfc2231_param *q; @@ -182,7 +175,7 @@ rfc2231_join_continuations(PARAMETER **head, rfc2231_param *par) vl = m_strlen(par->value); p_realloc(&value, l + vl + 1); - strcpy (value + l, par->value); /* __STRCPY_CHECKED__ */ + m_strcpy(value + l, vl + 1, par->value); l += vl; q = par->next; @@ -193,8 +186,8 @@ rfc2231_join_continuations(PARAMETER **head, rfc2231_param *par) if (value) { if (encoded) - mutt_convert_string (&value, charset, Charset, M_ICONV_HOOK_FROM); - *head = mutt_new_parameter (); + mutt_convert_string (&value, charset, MCharset.charset, M_ICONV_HOOK_FROM); + *head = parameter_new(); (*head)->attribute = m_strdup(attribute); (*head)->value = value; head = &(*head)->next; @@ -207,11 +200,11 @@ rfc2231_join_continuations(PARAMETER **head, rfc2231_param *par) /****************************************************************************/ /* XXX: MC: not read */ -void rfc2231_decode_parameters (PARAMETER ** headp) +void rfc2231_decode_parameters (parameter_t ** headp) { - PARAMETER *head = NULL; - PARAMETER **last; - PARAMETER *p, *q; + parameter_t *head = NULL; + parameter_t **last; + parameter_t *p, *q; rfc2231_param *conthead = NULL; rfc2231_param *conttmp; @@ -221,9 +214,7 @@ void rfc2231_decode_parameters (PARAMETER ** headp) int encoded; int idx; - short dirty = 0; /* set to 1 when we may have created - * empty parameters. - */ + short dirty = 0; /* 1 when we may have created empty parameters. */ if (!headp) return; @@ -242,11 +233,11 @@ void rfc2231_decode_parameters (PARAMETER ** headp) * Internet Gateways. So we actually decode it. */ - if (option (OPTRFC2047PARAMS) && p->value && strstr (p->value, "=?")) - rfc2047_decode (&p->value); - else if (!option (OPTSTRICTMIME)) { - if (ascii_strcasecmp (AssumedCharset, "us-ascii")) - mutt_convert_nonmime_string (&p->value); + if (p->value && strstr(p->value, "=?")) { + rfc2047_decode(&p->value); + } else { + if (mime_which_token(MCharset.assumed_charset, -1) == MIME_US_ASCII) + mutt_convert_nonmime_string(&p->value); } *last = p; @@ -258,7 +249,7 @@ void rfc2231_decode_parameters (PARAMETER ** headp) s = rfc2231_get_charset (p->value, charset, sizeof (charset)); rfc2231_decode_one (p->value, s); - mutt_convert_string (&p->value, charset, Charset, M_ICONV_HOOK_FROM); + mutt_convert_string (&p->value, charset, MCharset.charset, M_ICONV_HOOK_FROM); *last = p; last = &p->next; @@ -307,7 +298,7 @@ int rfc2231_encode_string(char **s) char *charset = NULL; char *e, *p, *t, *d = NULL; int escapes = 0; - size_t dlen = 0; + ssize_t dlen = 0; /* * A shortcut to detect pure 7bit data. @@ -322,13 +313,13 @@ int rfc2231_encode_string(char **s) return 0; } - if (Charset && SendCharset) { - charset = mutt_choose_charset(Charset, SendCharset, + if (MCharset.charset && MCharset.send_charset) { + charset = mutt_choose_charset(MCharset.charset, MCharset.send_charset, *s, m_strlen(*s), &d, &dlen); } if (!charset) { - charset = m_strdup(Charset ? Charset : "unknown-8bit"); + charset = m_strdup(MCharset.charset ?: "unknown-8bit"); d = *s; dlen = m_strlen(d); }