Blame SOURCES/0013-file-xfer-Fix-bad-filename-encoding.patch

6a5638
From bfd5040f4a082441c143c128d13063d28ddc1e32 Mon Sep 17 00:00:00 2001
6a5638
From: Victor Toso <me@victortoso.com>
6a5638
Date: Thu, 13 Apr 2017 14:32:55 +0200
6a5638
Subject: [PATCH 13/13] file-xfer: Fix bad filename encoding
6a5638
MIME-Version: 1.0
6a5638
Content-Type: text/plain; charset=UTF-8
6a5638
Content-Transfer-Encoding: 8bit
6a5638
6a5638
Manual for G_FILE_ATTRIBUTE_STANDARD_NAME states:
6a5638
 > The name is the on-disk filename which may not be in any known
6a5638
 > encoding, and can thus not be generally displayed as is.
6a5638
6a5638
Considering a file named "ěščřžýáíé", if we use
6a5638
G_FILE_ATTRIBUTE_STANDARD_NAME to get the file name, we will have the
6a5638
following 72 bytes long string:
6a5638
"\xc4\x9b\xc5\xa1\xc4\x8d\xc5\x99\xc5\xbe\xc3\xbd\xc3\xa1\xc3\xad\xc3\xa9"
6a5638
6a5638
This is a regression introduced at 4647ac9a2a72c98b6841180ccf5f8d
6a5638
6a5638
Possible solutions are:
6a5638
1) Using G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute;
6a5638
2) Using g_file_info_get_attribute_byte_string() function;
6a5638
3) Using the g_file_get_basename() which was used before 4647ac9a2a72c9
6a5638
6a5638
Using option 2 based on better long term solution.
6a5638
This give us the correct 18 bytes long utf-8 string to "ěščřžýáíé"
6a5638
6a5638
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1440206
6a5638
Signed-off-by: Victor Toso <victortoso@redhat.com>
6a5638
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
6a5638
(cherry picked from commit 5b9ad92814e3fc488cca8cba41b6af0caa390e1b)
6a5638
---
6a5638
 src/channel-main.c | 6 +++---
6a5638
 1 file changed, 3 insertions(+), 3 deletions(-)
6a5638
6a5638
diff --git a/src/channel-main.c b/src/channel-main.c
6a5638
index 990a06a..b0878dd 100644
6a5638
--- a/src/channel-main.c
6a5638
+++ b/src/channel-main.c
6a5638
@@ -2822,7 +2822,8 @@ static void file_xfer_init_task_async_cb(GObject *obj, GAsyncResult *res, gpoint
6a5638
     GFileInfo *info;
6a5638
     SpiceFileTransferTask *xfer_task;
6a5638
     SpiceMainChannel *channel;
6a5638
-    gchar *string, *basename;
6a5638
+    gchar *string;
6a5638
+    const gchar *basename;
6a5638
     GKeyFile *keyfile;
6a5638
     VDAgentFileXferStartMessage msg;
6a5638
     guint64 file_size;
6a5638
@@ -2837,7 +2838,7 @@ static void file_xfer_init_task_async_cb(GObject *obj, GAsyncResult *res, gpoint
6a5638
         goto failed;
6a5638
 
6a5638
     channel = spice_file_transfer_task_get_channel(xfer_task);
6a5638
-    basename = g_file_info_get_attribute_as_string(info, G_FILE_ATTRIBUTE_STANDARD_NAME);
6a5638
+    basename = g_file_info_get_attribute_byte_string(info, G_FILE_ATTRIBUTE_STANDARD_NAME);
6a5638
     file_size = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
6a5638
 
6a5638
     xfer_op = data;
6a5638
@@ -2846,7 +2847,6 @@ static void file_xfer_init_task_async_cb(GObject *obj, GAsyncResult *res, gpoint
6a5638
     keyfile = g_key_file_new();
6a5638
     g_key_file_set_string(keyfile, "vdagent-file-xfer", "name", basename);
6a5638
     g_key_file_set_uint64(keyfile, "vdagent-file-xfer", "size", file_size);
6a5638
-    g_free(basename);
6a5638
 
6a5638
     /* Save keyfile content to memory. TODO: more file attributions
6a5638
        need to be sent to guest */
6a5638
-- 
6a5638
2.12.2
6a5638