Try to decide what an @ in a location refers to

We assume the usual case is that you intend to search for an
email address, a host with a login isn't recognized.
This commit is contained in:
Christian Dywan 2009-04-12 14:00:32 +02:00
parent e7d20f467c
commit 89698772bb
2 changed files with 8 additions and 5 deletions

View file

@ -244,10 +244,10 @@ sokoke_magic_uri (const gchar* uri,
/* Do we have a domain, ip address or localhost? */ /* Do we have a domain, ip address or localhost? */
search = NULL; search = NULL;
if (!strchr (uri, ' ') && (search = strchr (uri, ':')) && if (!strchr (uri, ' ') &&
((search = strchr (uri, ':')) || (search = strchr (uri, '@'))) &&
search[0] && !g_ascii_isalpha (search[1])) search[0] && !g_ascii_isalpha (search[1]))
if (!strchr (search, '.')) return sokoke_idn_to_punycode (g_strconcat ("http://", uri, NULL));
return sokoke_idn_to_punycode (g_strconcat ("http://", uri, NULL));
if (!strcmp (uri, "localhost") || g_str_has_prefix (uri, "localhost/")) if (!strcmp (uri, "localhost") || g_str_has_prefix (uri, "localhost/"))
return g_strconcat ("http://", uri, NULL); return g_strconcat ("http://", uri, NULL);
parts = g_strsplit (uri, ".", 0); parts = g_strsplit (uri, ".", 0);

View file

@ -75,8 +75,9 @@ magic_uri_uri (void)
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 ("file:///home/mark/foo/bar.html", test_input ("file:///home/mark/foo/bar.html",
"file:///home/mark/foo/bar.html"); "file:///home/mark/foo/bar.html");
/* test_input ("foo:123@bar.baz", "foo:123@bar.baz"); */ test_input ("foo:123@bar.baz", "http://foo:123@bar.baz");
/* test_input ("foo:foo@bar.baz", "foo:foo@bar.baz"); */ /* test_input ("foo:f1o2o3@bar.baz", "http://f1o2o3:foo@bar.baz"); */
/* test_input ("foo:foo@bar.baz", "http://foo:foo@bar.baz"); */
} }
static void static void
@ -134,6 +135,8 @@ magic_uri_search (void)
SM "warning: configure /dev/net: virtual"); SM "warning: configure /dev/net: virtual");
test_input ("g \"ISO 9001:2000 certified\"", NULL); test_input ("g \"ISO 9001:2000 certified\"", NULL);
test_input ("g conference \"April 2, 7:00 am\"", NULL); test_input ("g conference \"April 2, 7:00 am\"", NULL);
test_input ("max@mustermann.de", NULL);
test_input ("g max@mustermann.de", NULL);
} }
static void static void