This is my attempt at adding IDNA2008 support. It is in branch
chris/idn-punycode (this is a condensed version but same as HEAD
there).
I've used libidn2 because it fully conforms to the spec, although I
can see there may be a benefit to not using an external library for
this. libidn2 seems to build cleanly with no patches on OS4 so I
don't envisage any major problems elsewhere, however I've made it
optional for now.
As I've put it in nsurl_create the non-ASCII hosts are automatically
handled everywhere in NetSurf, and are passed back to the frontend as
the punycode version so there should be no weird problems with
frontend string gadgets not supporting UTF-8.
I've tested the Amiga and GTK frontends and things like www.bücher.de
are handled correctly when typed in or clicked. Other frontends may
need to ensure any URLs typed in are passed as UTF-8.
---
Makefile.defaults | 4 ++++
amiga/Makefile.target | 2 ++
gtk/Makefile.target | 3 ++-
utils/nsurl.c | 25 ++++++++++++++++++++++---
4 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/Makefile.defaults b/Makefile.defaults
index e11fa1f..72374db 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -67,6 +67,10 @@ NETSURF_USE_MOZJS := AUTO
# Valid options: YES, NO
NETSURF_USE_HARU_PDF := NO
+# Enable NetSurf's use of libidn2 for international domain name parsing.
+# Valid options: YES, NO
+NETSURF_USE_IDN := YES
+
# Enable stripping the NetSurf binary
# Valid options: YES, NO
NETSURF_STRIP_BINARY := NO
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index b54fa1e..2fe62b6 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -30,6 +30,7 @@ ifeq ($(HOST),amiga)
$(eval $(call feature_enabled,AMIGA_CAIRO,-DNS_AMIGA_CAIRO,,Cairo))
$(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
$(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
+ $(eval $(call feature_enabled,IDN,-DWITH_IDN,-lidn2,IDNA2008))
CFLAGS += -I /SDK/local/common/include/libpng12
LDFLAGS += -lcurl -lrtmp -lpthread -ltre -lintl -lauto -lpbl
@@ -46,6 +47,7 @@ else
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
$(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,NSSVG))
$(eval $(call pkg_config_find_and_add_enabled,AMIGA_CAIRO,cairo,Cairo))
+ $(eval $(call feature_enabled,IDN,-DWITH_IDN,-lidn2,IDNA2008))
$(eval $(call feature_enabled,MOZJS,-DXP_AMIGA -DWITH_MOZJS -DJS_VERSION=170 -DJSVERSION_LATEST=170 -DJSOPTION_JIT=0 -DJSCLASS_GLOBAL_FLAGS=0,-ljs,JavaScript))
$(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
$(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index ec19d1b..ff1a450 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -20,7 +20,7 @@ NETSURF_FEATURE_MOZJS_CFLAGS := -DWITH_MOZJS -DJS_HAS_FILE_OBJECT=0
NETSURF_FEATURE_VIDEO_CFLAGS := -DWITH_VIDEO
# add a line similar to below for each optional lib here
-# note: webp lacks pkg-config file
+# note: webp and libidn2 lack pkg-config file
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
$(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF))
@@ -31,6 +31,7 @@ $(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp,WebP (libwebp)))
$(eval $(call pkg_config_find_and_add_enabled,MOZJS,mozjs185,JavaScript))
$(eval $(call pkg_config_find_and_add_enabled,JS,mozilla-js,JavaScript))
$(eval $(call pkg_config_find_and_add_enabled,VIDEO,gstreamer-0.10,Video))
+$(eval $(call feature_enabled,IDN,-DWITH_IDN,-lidn2,IDNA2008))
# GTK and GLIB flags to disable depricated usage
GTKDEPFLAGS := -DG_DISABLE_SINGLE_INCLUDES \
diff --git a/utils/nsurl.c b/utils/nsurl.c
index c99b0d3..e3d4845 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -25,7 +25,11 @@
#include <libwapcaplet/libwapcaplet.h>
#include <stdlib.h>
#include <string.h>
+#ifdef WITH_IDN
+#include <idn2.h>
+
No comments:
Post a Comment