[Xfce4-commits] <midori:master> Validate formatted URI, otherwise pass the original URI

Christian Dywan noreply at xfce.org
Sat Dec 12 01:26:07 CET 2009


Updating branch refs/heads/master
         to 63e3672632b2c062a0c593f56b5f1d6b46bd8786 (commit)
       from e403f2259bedfa74f7dedca08b418bfa76cd2031 (commit)

commit 63e3672632b2c062a0c593f56b5f1d6b46bd8786
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Dec 12 01:21:06 2009 +0100

    Validate formatted URI, otherwise pass the original URI
    
    Apparently g_uri_unescape_string can return invalid UTF8, so
    until we can replace or fix it, we double check to avoid
    crashing in g_markup_escape_text and other places.

 midori/sokoke.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/midori/sokoke.c b/midori/sokoke.c
index 823662a..932d8e6 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -610,6 +610,11 @@ sokoke_format_uri_for_display (const gchar* uri)
 
         if (!unescaped)
             return g_strdup (uri);
+        else if (!g_utf8_validate (unescaped, -1, NULL))
+        {
+            g_free (unescaped);
+            return g_strdup (uri);
+        }
 
         hostname = sokoke_hostname_from_uri (unescaped, &path);
         decoded = g_hostname_to_unicode (hostname);
@@ -629,6 +634,11 @@ sokoke_format_uri_for_display (const gchar* uri)
 
         if (!unescaped)
             return g_strdup (uri);
+        else if (!g_utf8_validate (unescaped, -1, NULL))
+        {
+            g_free (unescaped);
+            return g_strdup (uri);
+        }
 
         if (!idna_to_unicode_8z8z (unescaped, &decoded, 0) == IDNA_SUCCESS)
             return unescaped;



More information about the Xfce4-commits mailing list