[epiphany] Check for hostname:port in ephy_embed_utils_normalize_address ()
- From: Jan-Michael Brummer <jbrummer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Check for hostname:port in ephy_embed_utils_normalize_address ()
- Date: Sun, 17 Nov 2019 10:12:59 +0000 (UTC)
commit 564f38ccd5ba8fc12fbe79aa4b9d0ee46ad93005
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Wed Nov 13 19:21:40 2019 +0100
Check for hostname:port in ephy_embed_utils_normalize_address ()
Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/329
embed/ephy-embed-utils.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index da4c408d4..1a7dcc83a 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -211,6 +211,18 @@ is_bang_search (const char *address)
return FALSE;
}
+static gboolean
+is_host_with_port (const char *address)
+{
+ g_auto (GStrv) split = g_strsplit (address, ":", -1);
+ gint64 port = 0;
+
+ if (g_strv_length (split) == 2)
+ port = g_ascii_strtoll (split[1], NULL, 10);
+
+ return port != 0;
+}
+
gboolean
ephy_embed_utils_address_is_valid (const char *address)
{
@@ -232,7 +244,8 @@ ephy_embed_utils_address_is_valid (const char *address)
ephy_embed_utils_address_is_existing_absolute_filename (address) ||
g_regex_match (get_non_search_regex (), address, 0, NULL) ||
is_public_domain (address) ||
- is_bang_search (address);
+ is_bang_search (address) ||
+ is_host_with_port (address);
g_clear_object (&info);
@@ -266,7 +279,7 @@ ephy_embed_utils_normalize_address (const char *address)
return g_strconcat (EPHY_ABOUT_SCHEME, address + strlen ("about"), NULL);
if (!ephy_embed_utils_address_has_web_scheme (address)) {
- SoupURI *uri;
+ g_autoptr (SoupURI) uri = NULL;
uri = soup_uri_new (address);
@@ -280,11 +293,9 @@ ephy_embed_utils_normalize_address (const char *address)
* 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)))
+ (uri && g_hostname_is_ip_address (uri->scheme)) ||
+ (uri && is_host_with_port (address)))
effective_address = g_strconcat ("http://", address, NULL);
-
- if (uri)
- soup_uri_free (uri);
}
return effective_address ? effective_address : g_strdup (address);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]