Blame SOURCES/elinks-0.12pre6-libidn2.patch

06c6ff
From 496afe1f27481eb45ac14df0bfdb287b95eefbdd Mon Sep 17 00:00:00 2001
06c6ff
From: Robert Scheck <redhat-bugzilla@linuxnetz.de>
06c6ff
Date: Fri, 30 May 2014 15:28:54 +0200
06c6ff
Subject: [PATCH] Add support for GNU Libidn2
06c6ff
MIME-Version: 1.0
06c6ff
Content-Type: text/plain; charset=UTF-8
06c6ff
Content-Transfer-Encoding: 8bit
06c6ff
06c6ff
Patch by Robert Scheck <robert@fedoraproject.org> for elinks >= 0.12 which replaces current
06c6ff
GNU Libidn support (IDNA 2003) by GNU Libidn2 support (IDNA 2008). This is e.g. allowing
06c6ff
the 'ß' character in domain names. See also the Red Hat Bugzilla #1098789 for some further
06c6ff
information: https://bugzilla.redhat.com/show_bug.cgi?id=1098789
06c6ff
06c6ff
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
06c6ff
---
06c6ff
 Makefile.config.in      |  2 +-
06c6ff
 configure.in            |  4 ++--
06c6ff
 src/osdep/win32/win32.c |  2 +-
06c6ff
 src/protocol/uri.c      | 18 +++++++-----------
06c6ff
 4 files changed, 11 insertions(+), 15 deletions(-)
06c6ff
06c6ff
diff --git a/Makefile.config.in b/Makefile.config.in
06c6ff
index fe1a559..829d350 100644
06c6ff
--- a/Makefile.config.in
06c6ff
+++ b/Makefile.config.in
06c6ff
@@ -130,7 +130,7 @@ CONFIG_GOPHER = @CONFIG_GOPHER@
06c6ff
 CONFIG_GPM = @CONFIG_GPM@
06c6ff
 CONFIG_GZIP = @CONFIG_GZIP@
06c6ff
 CONFIG_HTML_HIGHLIGHT = @CONFIG_HTML_HIGHLIGHT@
06c6ff
-CONFIG_IDN = @CONFIG_IDN@
06c6ff
+CONFIG_IDN2 = @CONFIG_IDN2@
06c6ff
 CONFIG_INTERLINK = @CONFIG_INTERLINK@
06c6ff
 CONFIG_IPV6 = @CONFIG_IPV6@
06c6ff
 CONFIG_JW = @CONFIG_JW@
06c6ff
diff --git a/configure.in b/configure.in
06c6ff
index 3ef8603..3f74d9c 100644
06c6ff
--- a/configure.in
06c6ff
+++ b/configure.in
06c6ff
@@ -473,8 +473,8 @@ EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
06c6ff
 EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
06c6ff
 	[  --without-bzlib         disable bzlib support])
06c6ff
 
06c6ff
-EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN, idn, idna.h, idn, stringprep_check_version,
06c6ff
-	[  --without-idn           disable international domain names support])
06c6ff
+EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN2, idn2, idn2.h, idn2, idn2_lookup_ul,
06c6ff
+	[  --without-idn2           disable international domain names support])
06c6ff
 
06c6ff
 if test "x${with_gc}" != xno; then
06c6ff
 	EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GC, gc, gc.h, gc, GC_init,
06c6ff
diff --git a/src/osdep/win32/win32.c b/src/osdep/win32/win32.c
06c6ff
index 66b2128..e870a6e 100644
06c6ff
--- a/src/osdep/win32/win32.c
06c6ff
+++ b/src/osdep/win32/win32.c
06c6ff
@@ -48,7 +48,7 @@ init_osdep(void)
06c6ff
 #ifdef HAVE_LOCALE_H
06c6ff
 	setlocale(LC_ALL, "");
06c6ff
 #endif
06c6ff
-#ifdef CONFIG_IDN
06c6ff
+#ifdef CONFIG_IDN2
06c6ff
 	{
06c6ff
 		char buf[60];
06c6ff
 		UINT cp = GetACP();
06c6ff
diff --git a/src/protocol/uri.c b/src/protocol/uri.c
06c6ff
index 5e23ea2..8987567 100644
06c6ff
--- a/src/protocol/uri.c
06c6ff
+++ b/src/protocol/uri.c
06c6ff
@@ -6,8 +6,8 @@
06c6ff
 
06c6ff
 #include <ctype.h>
06c6ff
 #include <errno.h>
06c6ff
-#ifdef HAVE_IDNA_H
06c6ff
-#include <idna.h>
06c6ff
+#ifdef HAVE_IDN2_H
06c6ff
+#include <idn2.h>
06c6ff
 #endif
06c6ff
 #include <stdio.h>
06c6ff
 #include <stdlib.h>
06c6ff
@@ -531,24 +531,20 @@ add_uri_to_string(struct string *string, const struct uri *uri,
06c6ff
 		 * --pasky */
06c6ff
 		if (uri->ipv6 && wants(URI_PORT)) add_char_to_string(string, '[');
06c6ff
 #endif
06c6ff
-#ifdef CONFIG_IDN
06c6ff
+#ifdef CONFIG_IDN2
06c6ff
 		/* Support for the GNU International Domain Name library.
06c6ff
 		 *
06c6ff
-		 * http://www.gnu.org/software/libidn/manual/html_node/IDNA-Functions.html
06c6ff
-		 *
06c6ff
-		 * Now it is probably not perfect because idna_to_ascii_lz()
06c6ff
-		 * will be using a ``zero terminated input string encoded in
06c6ff
-		 * the current locale's character set''. Anyway I don't know
06c6ff
-		 * how to convert anything to UTF-8 or Unicode. --jonas */
06c6ff
+		 * http://www.gnu.org/software/libidn/libidn2/manual/libidn2.html
06c6ff
+		 */
06c6ff
 		if (wants(URI_IDN)) {
06c6ff
 			unsigned char *host = memacpy(uri->host, uri->hostlen);
06c6ff
 
06c6ff
 			if (host) {
06c6ff
 				char *idname;
06c6ff
-				int code = idna_to_ascii_lz(host, &idname, 0);
06c6ff
+				int code = idn2_lookup_ul(host, &idname, 0);
06c6ff
 
06c6ff
 				/* FIXME: Return NULL if it coughed? --jonas */
06c6ff
-				if (code == IDNA_SUCCESS) {
06c6ff
+				if (code == IDN2_OK) {
06c6ff
 					add_to_string(string, idname);
06c6ff
 					free(idname);
06c6ff
 					add_host = 0;
06c6ff
-- 
06c6ff
1.9.3
06c6ff