40#ifdef HAVE_STRINGPREP_H
41#include <stringprep.h>
42#elif defined(HAVE_IDN_STRINGPREP_H)
43#include <idn/stringprep.h>
45#define IDN2_SKIP_LIBIDN_COMPAT
48#elif defined(HAVE_IDN_IDN2_H)
50#elif defined(HAVE_IDNA_H)
52#elif defined(HAVE_IDN_IDNA_H)
56#if defined(HAVE_IDN2_H) || defined(HAVE_IDN_IDN2_H)
58#elif defined(HAVE_IDNA_H) || defined(HAVE_IDN_IDNA_H)
64#if (!defined(HAVE_IDNA_TO_ASCII_8Z) && defined(HAVE_IDNA_TO_ASCII_FROM_UTF8))
65#define idna_to_ascii_8z(input, output, flags) \
66 idna_to_ascii_from_utf8(input, output, (flags) &1, ((flags) &2) ? 1 : 0)
68#if (!defined(HAVE_IDNA_TO_ASCII_LZ) && defined(HAVE_IDNA_TO_ASCII_FROM_LOCALE))
69#define idna_to_ascii_lz(input, output, flags) \
70 idna_to_ascii_from_locale(input, output, (flags) &1, ((flags) &2) ? 1 : 0)
72#if (!defined(HAVE_IDNA_TO_UNICODE_8Z8Z) && defined(HAVE_IDNA_TO_UNICODE_UTF8_FROM_UTF8))
73#define idna_to_unicode_8z8z(input, output, flags) \
74 idna_to_unicode_utf8_from_utf8(input, output, (flags) &1, ((flags) &2) ? 1 : 0)
84static bool check_idn(
char *domain)
92 while ((domain = strchr(domain,
'.')))
115 if (!input || !output)
118#if (IDN_VERSION == 2)
119 return idn2_to_ascii_8z(input, output, flags | IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL);
121 return idna_to_ascii_lz(input, output, flags);
146 char *mailbox = NULL;
147 char *reversed_user = NULL, *reversed_domain = NULL;
154 bool is_idn_encoded = check_idn(local_domain);
156 if (is_idn_encoded && c_idn_decode)
158#if (IDN_VERSION == 2)
159 if (idn2_to_unicode_8z8z(local_domain, &tmp, IDN2_ALLOW_UNASSIGNED) != IDN2_OK)
161 if (idna_to_unicode_8z8z(local_domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
195 user, reversed_user);
212 if (is_idn_encoded && c_idn_decode)
214#if (IDN_VERSION == 2)
215 if (idn2_to_ascii_8z(reversed_domain, &tmp,
216 IDN2_ALLOW_UNASSIGNED | IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL) != IDN2_OK)
218 if (idna_to_ascii_8z(reversed_domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
232 domain, reversed_domain);
238 sprintf(mailbox,
"%s@%s",
NONULL(local_user),
NONULL(local_domain));
244 FREE(&reversed_domain);
245 FREE(&reversed_user);
266 char *mailbox = NULL;
284#if (IDN_VERSION == 2)
285 if (idn2_to_ascii_8z(intl_domain, &tmp,
286 IDN2_ALLOW_UNASSIGNED | IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL) != IDN2_OK)
288 if (idna_to_ascii_8z(intl_domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
298 sprintf(mailbox,
"%s@%s",
NONULL(intl_user),
NONULL(intl_domain));
316 static char vstring[256];
319#if (IDN_VERSION == 2)
320 snprintf(vstring,
sizeof(vstring),
"libidn2: %s (compiled with %s)",
321 idn2_check_version(NULL), IDN2_VERSION);
322#elif (IDN_VERSION == 1)
323 snprintf(vstring,
sizeof(vstring),
"libidn: %s (compiled with %s)",
324 stringprep_check_version(NULL), STRINGPREP_VERSION);
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string 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.
Convenience wrapper for the core headers.
#define mutt_debug(LEVEL,...)
Handling of international domain names.
int mutt_idna_to_ascii_lz(const char *input, char **output, uint8_t flags)
#define MI_MAY_BE_IRREVERSIBLE
const char * mutt_idna_print_version(void)
Create an IDN version string.
char * mutt_idna_local_to_intl(const char *user, const char *domain)
Convert an email's domain to Punycode.
char * mutt_idna_intl_to_local(const char *user, const char *domain, uint8_t flags)
Convert an email's domain from Punycode.
@ LL_DEBUG1
Log at debug level 1.
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
#define MUTT_ICONV_NO_FLAGS
No flags are set.
Convenience wrapper for the library headers.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.