Percent encode search terms, so '+' actually ends up as a '+'

This commit is contained in:
Christian Dywan 2009-04-19 00:47:02 +02:00
parent 52084a21e1
commit d7d6edbff3
3 changed files with 15 additions and 6 deletions

View file

@ -2547,10 +2547,15 @@ _action_location_submit_uri (GtkAction* action,
gint n; gint n;
new_uri = sokoke_magic_uri (uri, browser->search_engines); new_uri = sokoke_magic_uri (uri, browser->search_engines);
if (!new_uri && strstr (browser->location_entry_search, "%s")) if (!new_uri)
new_uri = g_strdup_printf (browser->location_entry_search, 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) else if (!new_uri)
new_uri = g_strconcat (browser->location_entry_search, uri, NULL); new_uri = g_strconcat (browser->location_entry_search, uri_, NULL);
g_free (uri_);
}
if (new_tab) if (new_tab)
{ {

View file

@ -279,11 +279,13 @@ sokoke_magic_uri (const gchar* uri,
if (parts[0] && parts[1]) if (parts[0] && parts[1])
if ((item = katze_array_find_token (search_engines, parts[0]))) 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); search_uri = katze_item_get_uri (item);
if (strstr (search_uri, "%s")) if (strstr (search_uri, "%s"))
search = g_strdup_printf (search_uri, parts[1]); search = g_strdup_printf (search_uri, uri_);
else else
search = g_strdup_printf ("%s%s", search_uri, parts[1]); search = g_strconcat (search_uri, uri_, NULL);
g_free (uri_);
} }
g_strfreev (parts); g_strfreev (parts);
return search; return search;

View file

@ -117,6 +117,8 @@ magic_uri_search (void)
test_input ("cats dogs", NULL); test_input ("cats dogs", NULL);
test_input ("gtk 2.0", NULL); test_input ("gtk 2.0", NULL);
test_input ("gtk2.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 ("midori0.1.0", NULL);
test_input ("midori 0.1.0", NULL); test_input ("midori 0.1.0", NULL);
test_input ("search:cats", NULL); test_input ("search:cats", NULL);