From 6b2187b5ef634f36b0096e9600f24c0de952c8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tyrychtr?= Date: Fri, 14 Mar 2025 13:46:55 +0100 Subject: [PATCH] gio-tool: Fix handling of the trash original path Previously, we were getting the string representation. However, this representation gets escaped, which breaks non-ascii characters, because we were counting on the path being the original path, which was not true in these cases. Retrieve it rather as the byte string which it is. Fixes #3636. --- gio/gio-tool-trash.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gio/gio-tool-trash.c b/gio/gio-tool-trash.c index 65a29f849..1fe2eb0ef 100644 --- a/gio/gio-tool-trash.c +++ b/gio/gio-tool-trash.c @@ -92,7 +92,7 @@ restore_trash (GFile *file, GFile *target = NULL; GFile *dir_target = NULL; gboolean ret = FALSE; - gchar *orig_path = NULL; + const gchar *orig_path = NULL; GError *local_error = NULL; info = g_file_query_info (file, G_FILE_ATTRIBUTE_TRASH_ORIG_PATH, G_FILE_QUERY_INFO_NONE, cancellable, &local_error); @@ -102,7 +102,7 @@ restore_trash (GFile *file, goto exit_func; } - orig_path = g_file_info_get_attribute_as_string (info, G_FILE_ATTRIBUTE_TRASH_ORIG_PATH); + orig_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_TRASH_ORIG_PATH); if (!orig_path) { g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, _("Unable to find original path")); @@ -110,7 +110,6 @@ restore_trash (GFile *file, } target = g_file_new_for_commandline_arg (orig_path); - g_free (orig_path); dir_target = g_file_get_parent (target); if (dir_target) @@ -173,7 +172,7 @@ trash_list (GFile *file, while ((info = g_file_enumerator_next_file (enumerator, cancellable, &local_error)) != NULL) { const char *name; - char *orig_path; + const char *orig_path; char *uri; GFile* child; @@ -181,12 +180,11 @@ trash_list (GFile *file, child = g_file_get_child (file, name); uri = g_file_get_uri (child); g_object_unref (child); - orig_path = g_file_info_get_attribute_as_string (info, G_FILE_ATTRIBUTE_TRASH_ORIG_PATH); + orig_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_TRASH_ORIG_PATH); g_print ("%s\t%s\n", uri, orig_path); g_object_unref (info); - g_free (orig_path); g_free (uri); }