Enable locale support for IDN at startup
authorPetr Menšík <pemensik@redhat.com>
Thu, 30 Sep 2021 20:15:39 +0000 (22:15 +0200)
committerSimon Kelley <simon@thekelleys.org.uk>
Wed, 6 Oct 2021 22:23:51 +0000 (23:23 +0100)
--address=/münchen.de/ is not accepted unless LOCALEDIR is defined on
build. It is not by default. If LIBIDN1 or 2 is defined, call setlocale
to initialize locale required to translate domains to ascii form.

Signed-off-by: Petr Menšík <pemensik@redhat.com>
src/dnsmasq.c

index 9516680..d3f2c13 100644 (file)
@@ -17,6 +17,9 @@
 /* Declare static char *compiler_opts  in config.h */
 #define DNSMASQ_COMPILE_OPTS
 
+#if defined(HAVE_IDN) || defined(HAVE_LIBIDN2) || defined(LOCALEDIR)
+#include <locale.h>
+#endif
 #include "dnsmasq.h"
 
 struct daemon *daemon;
@@ -69,8 +72,10 @@ int main (int argc, char **argv)
   int tftp_prefix_missing = 0;
 #endif
 
-#ifdef LOCALEDIR
+#if defined(HAVE_IDN) || defined(HAVE_LIBIDN2) || defined(LOCALEDIR)
   setlocale(LC_ALL, "");
+#endif
+#ifdef LOCALEDIR
   bindtextdomain("dnsmasq", LOCALEDIR); 
   textdomain("dnsmasq");
 #endif