[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:51:31 +0000 (UTC)
commit bd8d95fc38bb53df6256bba8f97a31ded88ca1cd
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 | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c
index de328d3b..8d5264ec 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri.c
@@ -618,10 +618,17 @@ 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_ascii_strcasecmp (scheme, "http") != 0 ||
+ g_ascii_strcasecmp (scheme, "https") != 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]