diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/setup.h | 1 | ||||
-rw-r--r-- | lib/url.c | 17 | ||||
-rw-r--r-- | lib/version.c | 16 |
3 files changed, 22 insertions, 12 deletions
diff --git a/lib/setup.h b/lib/setup.h index 0bbdbd5b3..cff891436 100644 --- a/lib/setup.h +++ b/lib/setup.h @@ -304,6 +304,7 @@ typedef struct in_addr Curl_ipconnect; /* This could benefit from additional checks that some of the used/important header files are present as well before we define the USE_* define. */ #define USE_LIBIDN +#define LIBIDN_REQUIRED_VERSION "0.4.5" #endif #endif /* __CONFIG_H */ @@ -87,6 +87,8 @@ #ifdef USE_LIBIDN #include <idna.h> #include <stringprep.h> +void idn_free (void *ptr); /* prototype from idn-free.h, not provided by + libidn 0.4.5's make install! */ #endif #ifdef HAVE_OPENSSL_ENGINE_H @@ -1390,13 +1392,13 @@ CURLcode Curl_disconnect(struct connectdata *conn) Curl_safefree(conn->host.rawalloc); /* host name buffer */ Curl_safefree(conn->proxy.rawalloc); /* proxy name buffer */ if(conn->host.encalloc) - (free)(conn->host.encalloc); /* encoded host name buffer, must be freed - with free() since this was allocated by - libidn */ + idn_free(conn->host.encalloc); /* encoded host name buffer, must be freed + with idn_free() since this was allocated + by libidn */ if(conn->proxy.encalloc) - (free)(conn->proxy.encalloc); /* encoded proxy name buffer, must be freed - with free() since this was allocated by - libidn */ + idn_free(conn->proxy.encalloc); /* encoded proxy name buffer, must be + freed with idn_free() since this was + allocated by libidn */ Curl_SSL_Close(conn); /* close possibly still open sockets */ @@ -1997,7 +1999,8 @@ static void fix_hostname(struct connectdata *conn, struct hostname *host) /************************************************************* * Check name for non-ASCII and convert hostname to ACE form. *************************************************************/ - if (!is_ASCII_name(host->name)) { + if (!is_ASCII_name(host->name) && + stringprep_check_version(LIBIDN_REQUIRED_VERSION)) { char *ace_hostname = NULL; struct SessionHandle *data = conn->data; int rc = idna_to_ascii_lz(host->name, &ace_hostname, 0); diff --git a/lib/version.c b/lib/version.c index 3f981e2b5..7bd4dbe50 100644 --- a/lib/version.c +++ b/lib/version.c @@ -132,8 +132,10 @@ char *curl_version(void) ptr += strlen(ptr); #endif #ifdef USE_LIBIDN - sprintf(ptr, " libidn/%s", stringprep_check_version(NULL)); - ptr += strlen(ptr); + if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) { + sprintf(ptr, " libidn/%s", stringprep_check_version(NULL)); + ptr += strlen(ptr); + } #endif return version; @@ -209,9 +211,6 @@ static curl_version_info_data version_info = { #if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4) | CURL_VERSION_LARGEFILE #endif -#ifdef USE_LIBIDN - | CURL_VERSION_IDN -#endif , NULL, /* ssl_version */ 0, /* ssl_version_num */ @@ -245,6 +244,13 @@ curl_version_info_data *curl_version_info(CURLversion stamp) version_info.ares_num = aresnum; } #endif +#ifdef USE_LIBIDN + /* This returns a version string if we use the given version or later, + otherwise it returns NULL */ + version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION); + if(version_info.libidn) + version_info.features |= CURL_VERSION_IDN; +#endif (void)stamp; /* avoid compiler warnings, we don't use this */ return &version_info; |