summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <dkolesa@igalia.com>2022-03-27 16:01:55 +0200
committerDaniel Kolesa <dkolesa@igalia.com>2022-04-06 16:58:04 +0200
commit4b9d9442f4b465e9403c4da399ccf6d7cc652eae (patch)
tree5309a20cf21e43170244ff29d7d6a9644740bdb4
parent2b5e3453ee0ab504eeecb8dbe76015e98ccbfcfb (diff)
downloadgvfs-4b9d9442f4b465e9403c4da399ccf6d7cc652eae.tar.gz
dav: Do not lose userinfo when copying URIs
The use of g_uri_build was also bad, since otherwise we would run into this: https://gitlab.gnome.org/GNOME/glib/-/issues/2619 While this should be fixed in glib, we need to work around this behavior for existing installations. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/614
-rw-r--r--daemon/gvfsbackenddav.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index f9d10a40..3ece9a5f 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -322,23 +322,6 @@ message_should_apply_redir_ref (SoupMessage *msg)
}
static GUri *
-dav_uri_dup_with (GUri *uri, const char *path, const char *userinfo)
-{
- if (!path && !userinfo)
- return g_uri_ref (uri);
-
- return g_uri_build (g_uri_get_flags (uri),
- g_uri_get_scheme (uri),
- userinfo ? userinfo : g_uri_get_userinfo (uri),
- g_uri_get_host (uri),
- g_uri_get_port (uri),
- path ? path : g_uri_get_path (uri),
- g_uri_get_query (uri),
- g_uri_get_fragment (uri));
-}
-
-
-static GUri *
g_vfs_backend_dav_uri_for_path (GVfsBackend *backend,
const char *path,
gboolean is_dir)
@@ -369,7 +352,7 @@ g_vfs_backend_dav_uri_for_path (GVfsBackend *backend,
else
new_path = g_build_path ("/", g_uri_get_path (mount_base), fn_encoded, "/", NULL);
- uri = dav_uri_dup_with (mount_base, new_path, NULL);
+ uri = soup_uri_copy (mount_base, SOUP_URI_PATH, new_path, SOUP_URI_NONE);
g_free (fn_encoded);
g_free (new_path);
@@ -432,7 +415,10 @@ g_vfs_backend_dav_redirect (SoupSession *session,
}
tmp = new_uri;
- new_uri = dav_uri_dup_with (new_uri, NULL, g_uri_get_userinfo (old_uri));
+ new_uri = soup_uri_copy (new_uri,
+ SOUP_URI_USER, g_uri_get_user (old_uri),
+ SOUP_URI_AUTH_PARAMS, g_uri_get_auth_params (old_uri),
+ SOUP_URI_NONE);
g_uri_unref (tmp);
/* Check if this is a trailing slash redirect (i.e. /a/b to /a/b/),
@@ -2141,7 +2127,7 @@ do_mount (GVfsBackend *backend,
new_path = path_get_parent_dir (last_good_path);
tmp = mount_base;
- mount_base = dav_uri_dup_with (mount_base, new_path, NULL);
+ mount_base = soup_uri_copy (mount_base, SOUP_URI_PATH, new_path, SOUP_URI_NONE);
g_uri_unref (tmp);
G_VFS_BACKEND_HTTP (backend)->mount_base = mount_base;
@@ -2222,7 +2208,7 @@ do_mount (GVfsBackend *backend,
/* Set the working path in mount path */
tmp = mount_base;
- mount_base = dav_uri_dup_with (mount_base, last_good_path, NULL);
+ mount_base = soup_uri_copy (mount_base, SOUP_URI_PATH, last_good_path, SOUP_URI_NONE);
g_uri_unref (tmp);
G_VFS_BACKEND_HTTP (backend)->mount_base = mount_base;
g_free (last_good_path);