summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2016-12-28 17:32:04 -0600
committerMichael Catanzaro <mcatanzaro@gnome.org>2016-12-28 17:32:04 -0600
commita720861364609bef172961cd7e99267a6fcf7f15 (patch)
treeaa5d0cef9db1754528b725b40f8bd8adda7744de /lib
parent60b68ef7e9767471ff5c26b25f052270b76e1bca (diff)
downloadepiphany-a720861364609bef172961cd7e99267a6fcf7f15.tar.gz
uri-helpers: Be more robust to invalid URIs
We tried to handle invalid URIs here but failed, since we free the SoupURI unconditionally.
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-uri-helpers.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index 8d913efbf..6a82221a3 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -282,9 +282,12 @@ ephy_uri_decode (const char *uri_string)
}
g_mutex_unlock (&idna_creation_mutex);
- /* Process any punycode in the host portion of the URI. */
uri = soup_uri_new (uri_string);
- if (uri != NULL && uri->host != NULL) {
+ if (uri == NULL)
+ return g_strdup (uri_string);
+
+ /* Process any punycode in the host portion of the URI. */
+ if (uri->host != NULL) {
/* +1 so there is space for the trailing NUL with the longest-possible
* domain name. +2 because ICU has this rather terrible behavior of
* sometimes returning a result that's not NUL-terminated if the buffer
@@ -305,7 +308,7 @@ ephy_uri_decode (const char *uri_string)
}
/* Note: this also strips passwords from the display URI. */
- percent_encoded_uri = uri != NULL ? soup_uri_to_string (uri, FALSE) : g_strdup (uri_string);
+ percent_encoded_uri = soup_uri_to_string (uri, FALSE);
soup_uri_free (uri);
/* Now, decode any percent-encoded characters in the URI. If there are null