katze_array_find_token may yield token without keywords
Also adapt the magic uri test.
This commit is contained in:
parent
df8284f650
commit
7e61fce9ca
2 changed files with 15 additions and 15 deletions
|
@ -3676,7 +3676,11 @@ _action_location_submit_uri (GtkAction* action,
|
||||||
if (browser->search_engines
|
if (browser->search_engines
|
||||||
&& (item = katze_array_find_token (browser->search_engines, uri)))
|
&& (item = katze_array_find_token (browser->search_engines, uri)))
|
||||||
{
|
{
|
||||||
keywords = strchr (uri, ' ') + 1;
|
keywords = strchr (uri, ' ');
|
||||||
|
if (keywords != NULL)
|
||||||
|
keywords++;
|
||||||
|
else
|
||||||
|
keywords = "";
|
||||||
search_uri = katze_item_get_uri (item);
|
search_uri = katze_item_get_uri (item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,26 +41,22 @@ test_input (const gchar* input,
|
||||||
uri = sokoke_magic_uri (input);
|
uri = sokoke_magic_uri (input);
|
||||||
if (!uri)
|
if (!uri)
|
||||||
{
|
{
|
||||||
gchar** parts;
|
const gchar* keywords = NULL;
|
||||||
gchar* keywords = NULL;
|
|
||||||
const gchar* search_uri = NULL;
|
const gchar* search_uri = NULL;
|
||||||
|
KatzeItem* item;
|
||||||
|
|
||||||
/* Do we have a keyword and a string? */
|
/* Do we have a keyword and a string? */
|
||||||
parts = g_strsplit (input, " ", 2);
|
if ((item = katze_array_find_token (search_engines, input)))
|
||||||
if (parts[0])
|
|
||||||
{
|
{
|
||||||
KatzeItem* item;
|
keywords = strchr (input, ' ');
|
||||||
if ((item = katze_array_find_token (search_engines, parts[0])))
|
if (keywords != NULL)
|
||||||
{
|
keywords++;
|
||||||
keywords = g_strdup (parts[1] ? parts[1] : "");
|
else
|
||||||
search_uri = katze_item_get_uri (item);
|
keywords = "";
|
||||||
}
|
search_uri = katze_item_get_uri (item);
|
||||||
}
|
}
|
||||||
g_strfreev (parts);
|
|
||||||
|
|
||||||
uri = keywords ? midori_uri_for_search (search_uri, keywords) : NULL;
|
uri = search_uri ? midori_uri_for_search (search_uri, keywords) : NULL;
|
||||||
|
|
||||||
g_free (keywords);
|
|
||||||
}
|
}
|
||||||
katze_assert_str_equal (input, uri, expected);
|
katze_assert_str_equal (input, uri, expected);
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
|
|
Loading…
Reference in a new issue