From 24420c21915ff74a8a13c284a1fa66aaff1e847b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 May 2004 07:40:00 +0000 Subject: [PATCH] Simon Josefsson added a idn_free() function in libidn 0.4.5 as a reaction to Gisle's previous mail. We now use this function, and thus we require libidn 0.4.5 or later. No earler version will do. --- CHANGES | 4 ++++ lib/setup.h | 1 + lib/url.c | 17 ++++++++++------- lib/version.c | 16 +++++++++++----- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index a4ea90706..40faf0056 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,10 @@ Changelog Daniel (24 May 2004) +- Simon Josefsson added a idn_free() function in libidn 0.4.5 as a reaction to + Gisle's previous mail. We now use this function, and thus we require libidn + 0.4.5 or later. No earler version will do. + - Robert D. Young reported that CURLOPT_COOKIEFILE and CURLOPT_COOKIE could not be used both in one request. Fixed it and added test case 172 to verify. 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 */ diff --git a/lib/url.c b/lib/url.c index d55086fed..de7601ebd 100644 --- a/lib/url.c +++ b/lib/url.c @@ -87,6 +87,8 @@ #ifdef USE_LIBIDN #include #include +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; @@ -208,9 +210,6 @@ static curl_version_info_data version_info = { #endif #if defined(ENABLE_64BIT) && (SIZEOF_CURL_OFF_T > 4) | CURL_VERSION_LARGEFILE -#endif -#ifdef USE_LIBIDN - | CURL_VERSION_IDN #endif , NULL, /* ssl_version */ @@ -244,6 +243,13 @@ curl_version_info_data *curl_version_info(CURLversion stamp) version_info.ares = ares_version(&aresnum); 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 */