[Xfce4-commits] <midori:master> Encode IDN addresses passed externally

Christian Dywan noreply at xfce.org
Sun Oct 4 16:28:02 CEST 2009


Updating branch refs/heads/master
         to acb2104128e98aa56fb9feedb3a69d0eee1881a4 (commit)
       from b53c39b82eabd8f10b656b14b0e125f58ef488c7 (commit)

commit acb2104128e98aa56fb9feedb3a69d0eee1881a4
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Oct 4 03:12:10 2009 +0200

    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 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index 60b6ad2..834e47d 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 35b95d5..7d40e8d 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 e2dbb21..ea23caa 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -42,6 +42,9 @@ 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);
 



More information about the Xfce4-commits mailing list