[libsoup/wip/soup-uri-removal] uri: Ensure normalized uris don't have an empty path
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [libsoup/wip/soup-uri-removal] uri: Ensure normalized uris don't have an empty path
- Date: Tue, 13 Oct 2020 15:28:34 +0000 (UTC)
commit aa4e32a91ba9147ffa108f7694b6191c2606dc1c
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Tue Oct 13 17:24:55 2020 +0200
    uri: Ensure normalized uris don't have an empty path
    
    GUri always returns a valid pointer for the path when parsing a string,
    but it can be the empty string, if the URI doesn't have a path. Soup
    assumes / is the path in those cases.
    
    Fixes server-test.
 libsoup/soup-uri.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c
index de328d3b..1d7f5830 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri.c
@@ -618,10 +618,15 @@ soup_uri_parse_normalized (GUri *base, const char *uri_string, GError **error)
                 return NULL;
 
         char *normalized_path, *normalized_query, *normalized_fragment;
-        normalized_path = path ? soup_uri_normalize (path, FALSE) : NULL;
+        normalized_path = soup_uri_normalize (path, FALSE);
         normalized_query = query ? soup_uri_normalize (query, FALSE) : NULL;
         normalized_fragment = fragment ? soup_uri_normalize (fragment, FALSE) : NULL;
-        remove_dot_segments (normalized_path);
+
+       remove_dot_segments (normalized_path);
+       if (*normalized_path == '\0') {
+               g_free (normalized_path);
+               normalized_path = g_strdup ("/");
+       }
 
         if (scheme && port == soup_scheme_default_port (scheme))
                 port = -1;
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]