[Xfce4-commits] <midori:master> Validate uri and title in completion in case of invalid UTF-8

Christian Dywan noreply at xfce.org
Sat Dec 12 18:06:01 CET 2009


Updating branch refs/heads/master
         to fb5d74d53f1017ce37df63171813fd1fb9aab94d (commit)
       from d1410ef73d2da0130146ca3a6191940a37a063c0 (commit)

commit fb5d74d53f1017ce37df63171813fd1fb9aab94d
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Dec 12 17:40:30 2009 +0100

    Validate uri and title in completion in case of invalid UTF-8

 midori/midori-locationaction.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c
index d2617db..525882c 100644
--- a/midori/midori-locationaction.c
+++ b/midori/midori-locationaction.c
@@ -664,7 +664,10 @@ midori_location_entry_render_text_cb (GtkCellLayout*   layout,
         : g_ascii_strdown (gtk_entry_get_text (GTK_ENTRY (entry)), -1);
     len = 0;
 
-    if (G_LIKELY (uri))
+    /* g_uri_unescape_segment () sometimes produces garbage */
+    if (G_UNLIKELY (uri && !g_utf8_validate (uri, -1, (const gchar **)&temp)))
+        temp[0]='\0';
+    else if (G_LIKELY (uri))
     {
         temp = g_utf8_strdown (uri, -1);
         if (key && *key && (start = strstr (temp, key)))
@@ -685,7 +688,11 @@ midori_location_entry_render_text_cb (GtkCellLayout*   layout,
     }
     if (uri && !desc_uri)
         desc_uri = g_markup_escape_text (uri, -1);
-    if (G_LIKELY (title))
+
+    /* g_uri_unescape_segment () sometimes produces garbage */
+    if (G_UNLIKELY (title && !g_utf8_validate (title, -1, (const gchar **)&temp)))
+        temp[0]='\0';
+    else if (G_LIKELY (title))
     {
         temp = g_utf8_strdown (title, -1);
         if (key && *key && (start = strstr (temp, key)))



More information about the Xfce4-commits mailing list