aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--embed/ephy-embed-utils.c16
-rw-r--r--tests/ephy-embed-utils-test.c4
2 files changed, 13 insertions, 7 deletions
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 2d58fc68b..e01842496 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -117,13 +117,15 @@ ephy_embed_utils_normalize_address (const char *address)
* auto-search this?" regex in EphyWebView, so we should be a
* valid-ish URL. Auto-prepend http:// to anything that is not
* one according to soup, because it probably will be
- * something like "google.com". Special case localhost(:port),
- * because SoupURI, correctly, thinks it is a URI with scheme
- * being localhost and, optionally, path being the
- * port. Ideally we should check if we have a handler for the
- * scheme, and since we'll fail for localhost, we'd fallback
- * to loading it as a domain. */
- if (!uri || (uri && !g_strcmp0 (uri->scheme, "localhost")))
+ * something like "google.com". Special case localhost(:port)
+ * and IP(:port), because SoupURI, correctly, thinks it is a
+ * URI with scheme being localhost/IP and, optionally, path
+ * being the port. Ideally we should check if we have a
+ * handler for the scheme, and since we'll fail for localhost
+ * and IP, we'd fallback to loading it as a domain. */
+ if (!uri ||
+ (uri && !g_strcmp0 (uri->scheme, "localhost")) ||
+ (uri && g_hostname_is_ip_address (uri->scheme)))
effective_address = g_strconcat ("http://", address, NULL);
else {
/* Convert about: schemes to ephy-about: in order to
diff --git a/tests/ephy-embed-utils-test.c b/tests/ephy-embed-utils-test.c
index 82731ba62..5d3bb77eb 100644
--- a/tests/ephy-embed-utils-test.c
+++ b/tests/ephy-embed-utils-test.c
@@ -56,6 +56,8 @@ static const SchemeTest tests_no_scheme[] = {
{ "mailto", "mailto:rupert@gnome.org" },
{ "hostname", "localhost" },
{ "hostname_with_port", "localhost:8080" },
+ { "ip_address", "192.168.0.1" },
+ { "ip_address_with_port", "192.168.0.1:8080" },
{ "http_no_double_colon", "http//www.gnome.org/" },
#if 0
{ "double_colon_first", ":var a=b;" },
@@ -75,6 +77,8 @@ static const NormalizeTest tests_normalize[] = {
#endif
{ "append_http_to_hostname", "gnome", "http://gnome" },
{ "append_http_to_hostname_with_port", "localhost:8080", "http://localhost:8080" },
+ { "append_http_to_ip_address", "192.168.0.1", "http://192.168.0.1" },
+ { "append_http_to_ip_address_with_port", "192.168.0.1:8080", "http://192.168.0.1:8080" },
{ "convert_about_to_ephy_about", "about:epiphany", "ephy-about:epiphany" },
{ "untouched_http", "http://gnome.org", "http://gnome.org" },
};