mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 21:33:09 +02:00
gio-tool: Do not alter uris before use
Uris may be altered by the following code, which breaks xdg-open: file = g_file_new_for_commandline_arg (arg[i]) uri = g_file_get_uri (file); Examples of possible uri changes: mailto:email -> mailto:///email magnet:?xt=urn:hash -> magnet:///?xt=urn:hash ssh://user@host -> sftp://user@host This patch causes that uris aren't preprocessed for locations with scheme, however absolute and relative paths are still preprocessed. https://bugzilla.gnome.org/show_bug.cgi?id=779182
This commit is contained in:
parent
f064be0998
commit
fe620e5def
@ -146,16 +146,28 @@ handle_open (int argc, char *argv[], gboolean do_help)
|
|||||||
success = TRUE;
|
success = TRUE;
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
GFile *file;
|
char *uri = NULL;
|
||||||
char *uri;
|
char *uri_scheme;
|
||||||
|
|
||||||
file = g_file_new_for_commandline_arg (argv[i]);
|
/* Workaround to handle non-URI locations. We still use the original
|
||||||
uri = g_file_get_uri (file);
|
* location for other cases, because GFile might modify the URI in ways
|
||||||
res = g_app_info_launch_default_for_uri (uri, NULL, &error);
|
* we don't want. See:
|
||||||
|
* https://bugzilla.gnome.org/show_bug.cgi?id=779182 */
|
||||||
|
uri_scheme = g_uri_parse_scheme (argv[i]);
|
||||||
|
if (!uri_scheme || uri_scheme[0] == '\0')
|
||||||
|
{
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
|
file = g_file_new_for_commandline_arg (argv[i]);
|
||||||
|
uri = g_file_get_uri (file);
|
||||||
|
g_object_unref (file);
|
||||||
|
}
|
||||||
|
g_free (uri_scheme);
|
||||||
|
|
||||||
|
res = g_app_info_launch_default_for_uri (uri ? uri : argv[i], NULL, &error);
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
print_file_error (file, error->message);
|
print_error ("%s: %s", uri ? uri : argv[i], error->message);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
@ -169,7 +181,7 @@ handle_open (int argc, char *argv[], gboolean do_help)
|
|||||||
char *bus_name = NULL;
|
char *bus_name = NULL;
|
||||||
char *object_path = NULL;
|
char *object_path = NULL;
|
||||||
|
|
||||||
if (get_bus_name_and_path_from_uri (uri, &bus_name, &object_path))
|
if (get_bus_name_and_path_from_uri (uri ? uri : argv[i], &bus_name, &object_path))
|
||||||
{
|
{
|
||||||
GDBusConnection *connection;
|
GDBusConnection *connection;
|
||||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
||||||
@ -189,7 +201,6 @@ handle_open (int argc, char *argv[], gboolean do_help)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_object_unref (file);
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user