[epiphany] uri-helpers: Be more robust to invalid URIs



commit a720861364609bef172961cd7e99267a6fcf7f15
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Wed Dec 28 17:32:04 2016 -0600

    uri-helpers: Be more robust to invalid URIs
    
    We tried to handle invalid URIs here but failed, since we free the
    SoupURI unconditionally.

 lib/ephy-uri-helpers.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index 8d913ef..6a82221 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]