]> spindle.queued.net Git - midori/commitdiff
Percent encode search terms, so '+' actually ends up as a '+'
authorChristian Dywan <christian@twotoasts.de>
Sat, 18 Apr 2009 22:47:02 +0000 (00:47 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sat, 18 Apr 2009 22:47:02 +0000 (00:47 +0200)
midori/midori-browser.c
midori/sokoke.c
tests/magic-uri.c

index d37eb49d5de5e0f2b8d107d09a070559572995da..1c521121d92d750e1f30788b87c254cb4c1da4ca 100644 (file)
@@ -2547,10 +2547,15 @@ _action_location_submit_uri (GtkAction*     action,
     gint n;
 
     new_uri = sokoke_magic_uri (uri, browser->search_engines);
-    if (!new_uri && strstr (browser->location_entry_search, "%s"))
-        new_uri = g_strdup_printf (browser->location_entry_search, uri);
-    else if (!new_uri)
-        new_uri = g_strconcat (browser->location_entry_search, uri, NULL);
+    if (!new_uri)
+    {
+        gchar* uri_ = g_uri_escape_string (uri, " :/", TRUE);
+        if (strstr (browser->location_entry_search, "%s"))
+            new_uri = g_strdup_printf (browser->location_entry_search, uri_);
+        else if (!new_uri)
+            new_uri = g_strconcat (browser->location_entry_search, uri_, NULL);
+        g_free (uri_);
+    }
 
     if (new_tab)
     {
index d6ad1afc13709174f18b9f2fc4b995781a2807da..adda646904eb3d60376292b3aeef53710e48c1ed 100644 (file)
@@ -279,11 +279,13 @@ sokoke_magic_uri (const gchar* uri,
     if (parts[0] && parts[1])
         if ((item = katze_array_find_token (search_engines, parts[0])))
         {
+            gchar* uri_ = g_uri_escape_string (parts[1], " :/", TRUE);
             search_uri = katze_item_get_uri (item);
             if (strstr (search_uri, "%s"))
-                search = g_strdup_printf (search_uri, parts[1]);
+                search = g_strdup_printf (search_uri, uri_);
             else
-                search = g_strdup_printf ("%s%s", search_uri, parts[1]);
+                search = g_strconcat (search_uri, uri_, NULL);
+            g_free (uri_);
         }
     g_strfreev (parts);
     return search;
index 381acd4c6cf36c87167c0db7476d019f83f3e81a..b8fbe445b74392808a948025dab197ad545ccb8e 100644 (file)
@@ -117,6 +117,8 @@ magic_uri_search (void)
     test_input ("cats dogs", NULL);
     test_input ("gtk 2.0", NULL);
     test_input ("gtk2.0", NULL);
+    test_input ("pcre++", NULL);
+    test_input ("sm pcre++", SM "pcre%2B%2B");
     test_input ("midori0.1.0", NULL);
     test_input ("midori 0.1.0", NULL);
     test_input ("search:cats", NULL);