[epiphany] embed-utils: do not try to prepend http:// to normalize a URL if it already has a web scheme
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] embed-utils: do not try to prepend http:// to normalize a URL if it already has a web scheme
- Date: Mon, 3 Mar 2014 13:35:20 +0000 (UTC)
commit c253296e67177277be9174912d6ca8cfe2be223a
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Feb 24 18:44:59 2014 +0100
embed-utils: do not try to prepend http:// to normalize a URL if it already has a web scheme
https://bugzilla.gnome.org/show_bug.cgi?id=725081
embed/ephy-embed-utils.c | 56 +++++++++++++++++++--------------------------
1 files changed, 24 insertions(+), 32 deletions(-)
---
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 26a0a62..94ce596 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -192,46 +192,38 @@ char*
ephy_embed_utils_normalize_address (const char *address)
{
char *effective_address = NULL;
- SoupURI *uri;
g_return_val_if_fail (address, NULL);
if (ephy_embed_utils_address_is_existing_absolute_filename (address))
return g_strconcat ("file://", address, NULL);
- uri = soup_uri_new (address);
-
- /* FIXME: if we are here we passed through the "should we
- * 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)
- * 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
- * force WebKit to delegate its handling to our
- * EphyRequestAbout. In general about: schemes are
- * handled internally by WebKit and mean "empty
- * document".
- */
- if (g_str_has_prefix (address, "about:") && !g_str_equal (address, "about:blank")) {
- effective_address = g_strconcat (EPHY_ABOUT_SCHEME, address + strlen ("about"), NULL);
- } else
- effective_address = g_strdup (address);
+ if (g_str_has_prefix (address, "about:") && !g_str_equal (address, "about:blank"))
+ return g_strconcat (EPHY_ABOUT_SCHEME, address + strlen ("about"), NULL);
+
+ if (!ephy_embed_utils_address_has_web_scheme (address)) {
+ SoupURI *uri;
+
+ uri = soup_uri_new (address);
+
+ /* 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)
+ * 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);
+
+ if (uri)
+ soup_uri_free (uri);
}
- if (uri)
- soup_uri_free (uri);
-
- return effective_address;
+ return effective_address ? effective_address : g_strdup (address);
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]