[Xfce4-commits] <midori:master> Don't mixup tokens starting with the same letters
Christian Dywan
noreply at xfce.org
Thu Aug 9 01:04:05 CEST 2012
Updating branch refs/heads/master
to e5da45a40ef01eccce9ed249eca37ab69f8fc829 (commit)
from 2e17639201aa33c7edd703136b2538f2af6c4450 (commit)
commit e5da45a40ef01eccce9ed249eca37ab69f8fc829
Author: Paweł Forysiuk <tuxator at o2.pl>
Date: Thu Aug 9 01:00:46 2012 +0200
Don't mixup tokens starting with the same letters
katze/katze-array.c | 9 +++++++--
tests/magic-uri.c | 12 ++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/katze/katze-array.c b/katze/katze-array.c
index 6d11b5a..602c164 100644
--- a/katze/katze-array.c
+++ b/katze/katze-array.c
@@ -404,8 +404,13 @@ katze_array_find_token (KatzeArray* array,
for (items = array->items; items; items = g_list_next (items))
{
const gchar* found_token = ((KatzeItem*)items->data)->token;
- if (found_token != NULL && !strncmp (token, found_token, token_length))
- return items->data;
+ if (found_token != NULL)
+ {
+ guint bigger_item = strlen (found_token) > token_length ? strlen (found_token) : token_length;
+
+ if (strncmp (token, found_token, bigger_item) == 0)
+ return items->data;
+ }
}
return NULL;
}
diff --git a/tests/magic-uri.c b/tests/magic-uri.c
index 35f5781..b80bf15 100644
--- a/tests/magic-uri.c
+++ b/tests/magic-uri.c
@@ -38,6 +38,16 @@ test_input (const gchar* input,
"token", "se", NULL);
katze_array_add_item (search_engines, item);
g_object_unref (item);
+ item = g_object_new (KATZE_TYPE_ITEM,
+ "uri", "ddg.gg",
+ "token", "dd", NULL);
+ katze_array_add_item (search_engines, item);
+ g_object_unref (item);
+ item = g_object_new (KATZE_TYPE_ITEM,
+ "uri", "google.com",
+ "token", "d", NULL);
+ katze_array_add_item (search_engines, item);
+ g_object_unref (item);
}
uri = sokoke_magic_uri (input);
@@ -160,6 +170,8 @@ static void
magic_uri_search (void)
{
test_input ("sm midori", SM "midori");
+ test_input ("d midori browser", "google.com" "midori%20browser");
+ test_input ("dd midori browser", "ddg.gg" "midori%20browser");
test_input ("sm cats dogs", SM "cats%20dogs");
test_input ("se cats dogs", SM "cats%20dogs");
test_input ("dict midori", NULL);
More information about the Xfce4-commits
mailing list