From 1fa03292c10f3724ed97be7e34e0905b5b5c67fa Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 20 Dec 2023 19:25:50 +0100 Subject: [PATCH] glocalvfs: Remove unnecessary and buggy code The code for stripping the query and fragment from file:// URIs was wrong, as it would not properly strip a query if there was a fragment. Fortunately, that code was actually useless, as the "stripped URI" was passed to g_filename_from_uri() that does proper stripping itself. So simply drop this extra unnecessary stripping logic from GLocalVFS's get_file_for_uri() and let g_filename_from_uri() do all the work. --- gio/glocalvfs.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/gio/glocalvfs.c b/gio/glocalvfs.c index 00fec8e2b..7266ee0f8 100644 --- a/gio/glocalvfs.c +++ b/gio/glocalvfs.c @@ -94,32 +94,9 @@ g_local_vfs_get_file_for_uri (GVfs *vfs, { char *path; GFile *file; - char *stripped_uri, *hash, *question_mark; - /* As per https://url.spec.whatwg.org/#file-state, file: URIs can contain - * query and fragment sections. We ignore them in order to get only the file - * path. Compliance to this part of the WhatWG spec doesn’t necessarily mean - * we comply with the entire spec. */ - if (strchr (uri, '#') != NULL) - { - stripped_uri = g_strdup (uri); - hash = strchr (stripped_uri, '#'); - *hash = 0; - } - else if (strchr (uri, '?') != NULL) - { - stripped_uri = g_strdup (uri); - question_mark = strchr (stripped_uri, '?'); - *question_mark = 0; - } - else - stripped_uri = (char *)uri; - - path = g_filename_from_uri (stripped_uri, NULL, NULL); + path = g_filename_from_uri (uri, NULL, NULL); - if (stripped_uri != uri) - g_free (stripped_uri); - if (path != NULL) file = _g_local_file_new (path); else