88 char *t = strchr(
value,
'\'');
98 char *u = strchr(t + 1,
'\'');
113 for (d = dest; *src; src++)
115 if ((src[0] ==
'%') && isxdigit((
unsigned char) src[1]) &&
116 isxdigit((
unsigned char) src[2]))
155 if ((c < 0) || ((c == 0) && (par->
index <= p->
index)))
190 char charset[256] = { 0 };
212 const size_t vl = strlen(par->
value);
250 char *s = NULL, *t = NULL;
251 char charset[256] = { 0 };
259 struct Parameter *np = NULL, *tmp = NULL;
277 if (c_rfc2047_parameters && np->
value && strstr(np->
value,
"=?"))
286 else if (s[1] ==
'\0')
308 for (t = s; (t[0] !=
'\0') && isdigit((
unsigned char) t[0]); t++)
311 encoded = (t[0] ==
'*');
318 if (!mutt_str_atoi_full(s, &index))
325 conttmp->
index = index;
357 if (!attribute || !value)
362 bool add_quotes =
false;
363 bool free_src_value =
false;
365 int continuation_number = 0;
366 size_t dest_value_len = 0, max_value_len = 0, cur_value_len = 0;
367 char *cur = NULL, *charset = NULL, *src_value = NULL;
374 for (cur = value; *cur; cur++)
376 if ((*cur < 0x20) || (*cur >= 0x7f))
387 if (c_charset && c_send_charset)
393 free_src_value =
true;
395 charset =
mutt_str_dup(c_charset ? c_charset :
"unknown-8bit");
404 for (cur = src_value; *cur; cur++)
411 if ((*cur < 0x20) || (*cur >= 0x7f) || strchr(
MimeSpecials, *cur) ||
423 if ((*cur ==
'\\') || (*cur ==
'"'))
434 (add_quotes ? 2 : 0) -
437 if (max_value_len < 30)
440 if (dest_value_len > max_value_len)
452 cur_value_len =
buf_len(cur_value);
467 while (*cur && (!split || (cur_value_len < max_value_len)))
471 if ((*cur < 0x20) || (*cur >= 0x7f) || strchr(
MimeSpecials, *cur) ||
487 if ((*cur ==
'\\') || (*cur ==
'"'))
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
const struct Slist * cs_subset_slist(const struct ConfigSubset *sub, const char *name)
Get a string-list config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
const char * cc_charset(void)
Get the cached value of $charset.
const struct Slist * cc_assumed_charset(void)
Get the cached value of $assumed_charset.
Convenience wrapper for the core headers.
int mutt_mb_filter_unprintable(char **s)
Replace unprintable characters.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
const char MimeSpecials[]
Characters that need special treatment in MIME.
Constants and macros for managing MIME encoding.
char * mutt_ch_choose(const char *fromcode, const struct Slist *charsets, const char *u, size_t ulen, char **d, size_t *dlen)
Figure the best charset to encode a string.
int mutt_ch_convert_nonmime_string(const struct Slist *const assumed_charset, const char *charset, char **ps)
Try to convert a string using a list of character sets.
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
#define MUTT_ICONV_HOOK_FROM
apply charset-hooks to fromcode
Convenience wrapper for the library headers.
bool slist_is_empty(const struct Slist *list)
Is the slist empty?
int mutt_str_cmp(const char *a, const char *b)
Compare two strings, safely.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
void mutt_param_free_one(struct Parameter **p)
Free a Parameter.
struct Parameter * mutt_param_new(void)
Create a new Parameter.
Store attributes associated with a MIME part.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
#define TAILQ_INSERT_TAIL(head, elm, field)
#define TAILQ_REMOVE(head, elm, field)
#define TAILQ_INSERT_HEAD(head, elm, field)
void rfc2047_decode(char **pd)
Decode any RFC2047-encoded header fields.
static int encode(const char *d, size_t dlen, int col, const char *fromcode, const struct Slist *charsets, char **e, size_t *elen, const char *specials)
RFC2047-encode a string.
RFC2047 MIME extensions encoding / decoding routines.
static void purge_empty_parameters(struct ParameterList *pl)
Remove any ill-formed Parameters from a list.
static void join_continuations(struct ParameterList *pl, struct Rfc2231Parameter *par)
Process continuation parameters.
static char * get_charset(char *value, char *charset, size_t chslen)
Get the charset from an RFC2231 header.
static void parameter_free(struct Rfc2231Parameter **ptr)
Free an Rfc2231Parameter.
static void list_insert(struct Rfc2231Parameter **list, struct Rfc2231Parameter *par)
Insert parameter into an ordered list.
void rfc2231_decode_parameters(struct ParameterList *pl)
Decode a Parameter list.
static struct Rfc2231Parameter * parameter_new(void)
Create a new Rfc2231Parameter.
size_t rfc2231_encode_string(struct ParameterList *head, const char *attribute, char *value)
Encode a string to be suitable for an RFC2231 header.
static void decode_one(char *dest, char *src)
Decode one percent-encoded character.
RFC2231 MIME Charset routines.
String manipulation buffer.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
Attribute associated with a MIME part.
char * attribute
Parameter name.
char * value
Parameter value.
bool encoded
Is the value encoded?
int index
Index number in the list.
char * value
Attribute value.
struct Rfc2231Parameter * next
Linked list.
char * attribute
Attribute name.
struct ListHead head
List containing values.
size_t count
Number of values in list.