Blame SOURCES/elinks-0.12pre6-libidn2.patch

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