]> spindle.queued.net Git - midori/commitdiff
Encode IDN addresses passed externally
authorChristian Dywan <christian@twotoasts.de>
Sun, 4 Oct 2009 01:12:10 +0000 (03:12 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 4 Oct 2009 01:12:10 +0000 (03:12 +0200)
Apparently libUnique can't handle international domains and
won't pass them onto the destined instance, so we encode
them beforehand.

midori/main.c
midori/sokoke.c
midori/sokoke.h

index 60b6ad27da0f6e4d6e2a13cd986f9b7884d90eb9..834e47d5026daa949e2e9caa5d02c81f2479e3f6 100644 (file)
@@ -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
index 35b95d5a6e5041af0045086d964bf1fc3697d388..7d40e8d0769a756cbd2cbceefb2d75356101565a 100644 (file)
@@ -185,7 +185,7 @@ sokoke_spawn_program (const gchar* command,
     return TRUE;
 }
 
-static gchar*
+gchar*
 sokoke_idn_to_punycode (gchar* uri)
 {
     #if HAVE_LIBIDN
index e2dbb210c073d96bd989032b0d9f72255d202679..ea23caafaad7e8fe1c09b066460d431d04645e06 100644 (file)
@@ -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);