Take special care of spaces in search strings

This commit is contained in:
Christian Dywan 2008-11-21 02:44:03 +01:00
parent fdb12aa537
commit 600423de4e
2 changed files with 13 additions and 4 deletions

View file

@ -125,6 +125,7 @@ sokoke_magic_uri (const gchar* uri,
{ {
search = NULL; search = NULL;
if (!(parts[1][1] == '\0' && !g_ascii_isalpha (parts[1][0]))) if (!(parts[1][1] == '\0' && !g_ascii_isalpha (parts[1][0])))
if (!strchr (parts[0], ' ') && !strchr (parts[1], ' '))
search = g_strconcat ("http://", uri, NULL); search = g_strconcat ("http://", uri, NULL);
g_free (parts); g_free (parts);
if (search) if (search)

View file

@ -44,6 +44,7 @@ main (int argc,
return 1; \ return 1; \
} \ } \
g_free (uri) g_free (uri)
#define SM "http://www.searchmash.com/search/"
test_input ("ftp://ftp.mozilla.org", "ftp://ftp.mozilla.org"); test_input ("ftp://ftp.mozilla.org", "ftp://ftp.mozilla.org");
test_input ("ftp://ftp.mozilla.org/pub", "ftp://ftp.mozilla.org/pub"); test_input ("ftp://ftp.mozilla.org/pub", "ftp://ftp.mozilla.org/pub");
@ -61,8 +62,8 @@ main (int argc,
test_input ("localhost:8000", "http://localhost:8000"); test_input ("localhost:8000", "http://localhost:8000");
test_input ("192.168.1.1", "http://192.168.1.1"); test_input ("192.168.1.1", "http://192.168.1.1");
test_input ("192.168.1.1:8000", "http://192.168.1.1:8000"); test_input ("192.168.1.1:8000", "http://192.168.1.1:8000");
test_input ("sm midori", "http://www.searchmash.com/search/midori"); test_input ("sm midori", SM "midori");
test_input ("sm cats dogs", "http://www.searchmash.com/search/cats dogs"); test_input ("sm cats dogs", SM "cats dogs");
test_input ("dict midori", NULL); test_input ("dict midori", NULL);
test_input ("cats", NULL); test_input ("cats", NULL);
test_input ("cats dogs", NULL); test_input ("cats dogs", NULL);
@ -74,7 +75,14 @@ main (int argc,
test_input ("search:twotoasts.de", NULL); test_input ("search:twotoasts.de", NULL);
test_input ("g cache:127.0.0.1", NULL); test_input ("g cache:127.0.0.1", NULL);
test_input ("g cache:127.0.0.1/foo", NULL); test_input ("g cache:127.0.0.1/foo", NULL);
test_input ("g cache:twotoats.de/foo", NULL); test_input ("g cache:twotoasts.de/foo", NULL);
test_input ("sm cache:127.0.0.1", SM "cache:127.0.0.1");
test_input ("sm cache:127.0.0.1/foo", SM "cache:127.0.0.1/foo");
test_input ("sm cache:twotoasts.de/foo", SM "cache:twotoasts.de/foo");
test_input ("de.po verbose", NULL);
test_input ("verbose de.po", NULL);
test_input ("g de.po verbose", NULL);
test_input ("sm de.po verbose", SM "de.po verbose");
return 0; return 0;
} }