From d7d6edbff3ee892efd7f996e4a8c6b8d310befac Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 19 Apr 2009 00:47:02 +0200 Subject: [PATCH] Percent encode search terms, so '+' actually ends up as a '+' --- midori/midori-browser.c | 13 +++++++++---- midori/sokoke.c | 6 ++++-- tests/magic-uri.c | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index d37eb49d..1c521121 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -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) { diff --git a/midori/sokoke.c b/midori/sokoke.c index d6ad1afc..adda6469 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -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; diff --git a/tests/magic-uri.c b/tests/magic-uri.c index 381acd4c..b8fbe445 100644 --- a/tests/magic-uri.c +++ b/tests/magic-uri.c @@ -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);