From acb2104128e98aa56fb9feedb3a69d0eee1881a4 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 4 Oct 2009 03:12:10 +0200 Subject: [PATCH] Encode IDN addresses passed externally Apparently libUnique can't handle international domains and won't pass them onto the destined instance, so we encode them beforehand. --- midori/main.c | 16 ++++++++++++++++ midori/sokoke.c | 2 +- midori/sokoke.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/midori/main.c b/midori/main.c index 60b6ad27..834e47d5 100644 --- a/midori/main.c +++ b/midori/main.c @@ -1772,6 +1772,22 @@ main (int argc, { /* TODO: Open a tab per URI, seperated by pipes */ /* FIXME: Handle relative files or magic URI here */ + /* Encode any IDN addresses because libUnique doesn't like them */ + i = 0; + while (uris[i] != NULL) + { + #if GLIB_CHECK_VERSION (2, 22, 0) + gchar* encoded = g_hostname_to_unicode (uris[i]); + if (encoded) + { + g_free (uris[i]); + uris[i] = encoded; + } + #else + uris[i] = sokoke_idn_to_punycode (uris[i]); + #endif + i++; + } result = midori_app_instance_send_uris (app, uris); } else diff --git a/midori/sokoke.c b/midori/sokoke.c index 35b95d5a..7d40e8d0 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -185,7 +185,7 @@ sokoke_spawn_program (const gchar* command, return TRUE; } -static gchar* +gchar* sokoke_idn_to_punycode (gchar* uri) { #if HAVE_LIBIDN diff --git a/midori/sokoke.h b/midori/sokoke.h index e2dbb210..ea23caaf 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -41,6 +41,9 @@ sokoke_spawn_program (const gchar* command, gchar* sokoke_search_uri (const gchar* uri, const gchar* keywords); +gchar* +sokoke_idn_to_punycode (gchar* uri); + gchar* sokoke_magic_uri (const gchar* uri, KatzeArray* search_engines); -- 2.39.5