Better fix for bug #3009; conv_filename_to_utf8() converts strings
authorColin Leroy <colin@colino.net>
Thu, 5 Dec 2013 11:05:24 +0000 (12:05 +0100)
committerColin Leroy <colin@colino.net>
Thu, 5 Dec 2013 11:05:24 +0000 (12:05 +0100)
in local filename encoding to UTF-8 even if local filename encoding
is UTF-8, leading to double UTF-8 encoding.

src/folder.c

index b9a3dc3..676c7a9 100644 (file)
@@ -334,9 +334,9 @@ XMLTag *folder_get_xml(Folder *folder)
 FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path)
 {
        FolderItem *item = NULL;
-       
+
        cm_return_val_if_fail(folder != NULL, NULL);
-       
+
        if (folder->klass->item_new) {
                item = folder->klass->item_new(folder);
        } else {
@@ -346,7 +346,14 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
        cm_return_val_if_fail(item != NULL, NULL);
 
        item->stype = F_NORMAL;
-       item->name = conv_filename_to_utf8(name);
+
+       if(!g_utf8_validate(name, -1, NULL)) {
+               item->name = g_malloc(strlen(name)*2+1);
+               conv_localetodisp(item->name, strlen(name)*2+1, name);
+       } else {
+               item->name = g_strdup(name);
+       }
+
        item->path = g_strdup(path);
        item->mtime = 0;
        item->new_msgs = 0;