mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
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.
This commit is contained in:
parent
5790ce14e8
commit
1fa03292c1
@ -94,31 +94,8 @@ g_local_vfs_get_file_for_uri (GVfs *vfs,
|
|||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
GFile *file;
|
GFile *file;
|
||||||
char *stripped_uri, *hash, *question_mark;
|
|
||||||
|
|
||||||
/* As per https://url.spec.whatwg.org/#file-state, file: URIs can contain
|
path = g_filename_from_uri (uri, NULL, NULL);
|
||||||
* 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);
|
|
||||||
|
|
||||||
if (stripped_uri != uri)
|
|
||||||
g_free (stripped_uri);
|
|
||||||
|
|
||||||
if (path != NULL)
|
if (path != NULL)
|
||||||
file = _g_local_file_new (path);
|
file = _g_local_file_new (path);
|
||||||
|
Loading…
Reference in New Issue
Block a user