From: short <> Date: Sat, 13 Dec 2003 19:04:32 +0000 (+0000) Subject: Fixed "mv dir dir/subdir" prevention for UTF8 filenames case-insensitivity. X-Git-Tag: captive-1_1_4~6 X-Git-Url: https://git.jankratochvil.net/?p=captive.git;a=commitdiff_plain;h=4f62c109847984e651ca6507a2c6488c792f54ab Fixed "mv dir dir/subdir" prevention for UTF8 filenames case-insensitivity. --- diff --git a/src/libcaptive/client/file-parent.c b/src/libcaptive/client/file-parent.c index c7d999f..1338ede 100644 --- a/src/libcaptive/client/file-parent.c +++ b/src/libcaptive/client/file-parent.c @@ -522,6 +522,7 @@ static GnomeVFSResult captive_file_parent_move CaptiveFileParentObject *captive_file_parent_object_old; GnomeVFSResult r; gint retried=0; +gchar *chksub_pathname_old_cased,*chksub_pathname_new_cased; /* case-sensitive version */ gchar *chksub_pathname_old,*chksub_pathname_new,*chksub_s_old,*chksub_s_new; g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_object_old),GNOME_VFS_ERROR_BAD_PARAMETERS); @@ -530,10 +531,16 @@ gchar *chksub_pathname_old,*chksub_pathname_new,*chksub_s_old,*chksub_s_new; captive_file_parent_object_old=CAPTIVE_FILE_PARENT_OBJECT(captive_file_object_old); /* Prevent "mv dir dir/subdir" as it is not catched by ntfs.sys of NT-5.1sp1. */ - /* FIXME: UTF8/Unicode */ /* FIXME: Move to 'CaptiveFileSlaveObject' but it has no '->pathname' stored now! */ - chksub_pathname_old=captive_path_normalize(captive_file_parent_object_old->pathname); - chksub_pathname_new=captive_path_normalize(pathname_new); + /* FIXME: UTF8 may not be compared correctly - we should use g_utf8_collate() */ + chksub_pathname_old_cased=captive_path_normalize(captive_file_parent_object_old->pathname); + chksub_pathname_new_cased=captive_path_normalize(pathname_new); + chksub_pathname_old=g_utf8_casefold(chksub_pathname_old_cased, + -1); /* len; '\0'-terminated */ + chksub_pathname_new=g_utf8_casefold(chksub_pathname_new_cased, + -1); /* len; '\0'-terminated */ + g_free(chksub_pathname_old_cased); + g_free(chksub_pathname_new_cased); for ( chksub_s_old=chksub_pathname_old,chksub_s_new=chksub_pathname_new; *chksub_s_old && *chksub_s_new && tolower(*chksub_s_old)==tolower(*chksub_s_new);