Add glib2 dependency to support IDN
[platform/upstream/curl.git] / lib / url.c
index 3282566..8692e68 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -65,6 +65,8 @@
 #elif defined(USE_WIN32_IDN)
 /* prototype for curl_win32_idn_to_ascii() */
 bool curl_win32_idn_to_ascii(const char *in, char **out);
+#elif defined(USE_GLIB2_HOSTNAME)
+#include <glib.h>
 #endif  /* USE_LIBIDN2 */
 
 #include "urldata.h"
@@ -4072,6 +4074,15 @@ static void fix_hostname(struct connectdata *conn, struct hostname *host)
     }
     else
       infof(data, "Failed to convert %s to ACE;\n", host->name);
+#elif defined(USE_GLIB2_HOSTNAME)
+    gchar *ace_hostname = NULL;
+    ace_hostname = g_hostname_to_ascii(host->name);
+    if(ace_hostname) {
+      host->encalloc = (char *)ace_hostname;
+      host->name = host->encalloc;
+    }
+    else
+      infof(data, "Failed to convert %s to ACE;\n", host->name);
 #else
     infof(data, "IDN support not present, can't parse Unicode domains\n");
 #endif