From 700ddca7637b4d3ada2c9c974cf11e9d37ec4c0e Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 23 Mar 2019 01:00:13 +0000 Subject: [PATCH] build: fix a bunch of idn2-related problems - hide code if IDN is disabled - fix build tests - add travis dependency --- .travis.yml | 1 + address/idna.c | 4 ++++ auto.def | 1 + test/idna/main.c | 8 ++++---- test/idna/mutt_idna_intl_to_local.c | 2 ++ test/idna/mutt_idna_local_to_intl.c | 2 ++ test/idna/mutt_idna_print_version.c | 2 ++ test/idna/mutt_idna_to_ascii_lz.c | 6 ++++-- 8 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index c55a85d93..439c39dd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ addons: - libgnutls-dev - libgpgme11-dev - libgss-dev + - libidn2-0-dev - libkyotocabinet-dev - liblmdb-dev - liblua5.2-dev diff --git a/address/idna.c b/address/idna.c index 539b35aaf..ef7861e8d 100644 --- a/address/idna.c +++ b/address/idna.c @@ -38,6 +38,7 @@ #include #endif #ifdef HAVE_IDN2_H +#include #include #elif defined(HAVE_IDN_IDN2_H) #include @@ -106,6 +107,9 @@ static bool check_idn(char *domain) */ int mutt_idna_to_ascii_lz(const char *input, char **output, int flags) { + if (!input || !output) + return 1; + return idna_to_ascii_lz(input, output, flags); } #endif /* HAVE_LIBIDN */ diff --git a/auto.def b/auto.def index 298756a1d..54f432cb6 100644 --- a/auto.def +++ b/auto.def @@ -717,6 +717,7 @@ if {[get-define want-idn]} { cc-with [list -cflags -I$idn_prefix/include -libs -L$idn_prefix/lib] { set idn2 [cc-check-includes idn2.h] incr idn2 [cc-check-includes idn/idn2.h] + set sprcv [cc-check-function-in-lib stringprep_check_version idn] set lu8 [cc-check-function-in-lib idn2_lookup_u8 idn2] if {$idn2 == 0 || $lu8 == 0} { user-error "Unable to find GNU libidn2" diff --git a/test/idna/main.c b/test/idna/main.c index 88fd31178..929b9bb4d 100644 --- a/test/idna/main.c +++ b/test/idna/main.c @@ -26,10 +26,10 @@ * Add your test cases to this list. *****************************************************************************/ #define NEOMUTT_TEST_LIST \ - NEOMUTT_TEST_ITEM(mutt_idna_intl_to_local) \ - NEOMUTT_TEST_ITEM(mutt_idna_local_to_intl) \ - NEOMUTT_TEST_ITEM(mutt_idna_print_version) \ - NEOMUTT_TEST_ITEM(mutt_idna_to_ascii_lz) + NEOMUTT_TEST_ITEM(test_mutt_idna_intl_to_local) \ + NEOMUTT_TEST_ITEM(test_mutt_idna_local_to_intl) \ + NEOMUTT_TEST_ITEM(test_mutt_idna_print_version) \ + NEOMUTT_TEST_ITEM(test_mutt_idna_to_ascii_lz) /****************************************************************************** * You probably don't need to touch what follows. diff --git a/test/idna/mutt_idna_intl_to_local.c b/test/idna/mutt_idna_intl_to_local.c index a6e0e6d0e..bd41e7c80 100644 --- a/test/idna/mutt_idna_intl_to_local.c +++ b/test/idna/mutt_idna_intl_to_local.c @@ -30,6 +30,7 @@ void test_mutt_idna_intl_to_local(void) { // char * mutt_idna_intl_to_local(const char *user, const char *domain, int flags); +#ifdef HAVE_LIBIDN { TEST_CHECK(!mutt_idna_intl_to_local(NULL, "banana", 0)); } @@ -37,4 +38,5 @@ void test_mutt_idna_intl_to_local(void) { TEST_CHECK(!mutt_idna_intl_to_local("apple", NULL, 0)); } +#endif } diff --git a/test/idna/mutt_idna_local_to_intl.c b/test/idna/mutt_idna_local_to_intl.c index 63657cd7a..342f49f5e 100644 --- a/test/idna/mutt_idna_local_to_intl.c +++ b/test/idna/mutt_idna_local_to_intl.c @@ -30,6 +30,7 @@ void test_mutt_idna_local_to_intl(void) { // char * mutt_idna_local_to_intl(const char *user, const char *domain); +#ifdef HAVE_LIBIDN { TEST_CHECK(!mutt_idna_local_to_intl(NULL, "banana")); } @@ -37,4 +38,5 @@ void test_mutt_idna_local_to_intl(void) { TEST_CHECK(!mutt_idna_local_to_intl("apple", NULL)); } +#endif } diff --git a/test/idna/mutt_idna_print_version.c b/test/idna/mutt_idna_print_version.c index a477e7029..e296ed9a2 100644 --- a/test/idna/mutt_idna_print_version.c +++ b/test/idna/mutt_idna_print_version.c @@ -29,4 +29,6 @@ void test_mutt_idna_print_version(void) { // const char *mutt_idna_print_version(void); +#ifdef HAVE_LIBIDN +#endif } diff --git a/test/idna/mutt_idna_to_ascii_lz.c b/test/idna/mutt_idna_to_ascii_lz.c index bf45b32d8..3abf7f644 100644 --- a/test/idna/mutt_idna_to_ascii_lz.c +++ b/test/idna/mutt_idna_to_ascii_lz.c @@ -30,12 +30,14 @@ void test_mutt_idna_to_ascii_lz(void) { // int mutt_idna_to_ascii_lz(const char *input, char **output, int flags); +#ifdef HAVE_LIBIDN { char *out = NULL; - TEST_CHECK(mutt_idna_to_ascii_lz(NULL, &out, 0) == -1); + TEST_CHECK(mutt_idna_to_ascii_lz(NULL, &out, 0) != 0); } { - TEST_CHECK(mutt_idna_to_ascii_lz("apple", NULL, 0) == -1); + TEST_CHECK(mutt_idna_to_ascii_lz("apple", NULL, 0) != 0); } +#endif } -- 2.40.0