mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Merge branch '2791_path_encoding'
* 2791_path_encoding: Ticket #2791: Fixed: cannot Copy/Move files with filename encoding change
This commit is contained in:
commit
961019d078
@ -142,6 +142,16 @@ vfs_canon (const char *path)
|
|||||||
{
|
{
|
||||||
char *result, *local;
|
char *result, *local;
|
||||||
|
|
||||||
|
if (g_str_has_prefix (path, VFS_ENCODING_PREFIX))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
encoding prefix placed at start of string without the leading slash
|
||||||
|
should be autofixed by adding the leading slash
|
||||||
|
*/
|
||||||
|
local = mc_build_filename (PATH_SEP_STR, path, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
local = tilde_expand (path);
|
local = tilde_expand (path);
|
||||||
if (*local != PATH_SEP)
|
if (*local != PATH_SEP)
|
||||||
{
|
{
|
||||||
@ -152,7 +162,7 @@ vfs_canon (const char *path)
|
|||||||
local = mc_build_filename (curr_dir, path, NULL);
|
local = mc_build_filename (curr_dir, path, NULL);
|
||||||
g_free (curr_dir);
|
g_free (curr_dir);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
result = vfs_canon (local);
|
result = vfs_canon (local);
|
||||||
g_free (local);
|
g_free (local);
|
||||||
return result;
|
return result;
|
||||||
@ -423,6 +433,7 @@ vfs_path_from_str_deprecated_parser (char *path, vfs_path_flag_t flags)
|
|||||||
/** Split path string to path elements by URL algorithm.
|
/** Split path string to path elements by URL algorithm.
|
||||||
*
|
*
|
||||||
* @param path_str VFS-path
|
* @param path_str VFS-path
|
||||||
|
* @param flags flags for converter
|
||||||
*
|
*
|
||||||
* @return pointer to newly created vfs_path_t object with filled path elements array.
|
* @return pointer to newly created vfs_path_t object with filled path elements array.
|
||||||
*/
|
*/
|
||||||
|
@ -60,6 +60,31 @@ teardown (void)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void test_init_vfs(const char *encoding)
|
||||||
|
{
|
||||||
|
str_init_strings (encoding);
|
||||||
|
|
||||||
|
vfs_init ();
|
||||||
|
init_localfs ();
|
||||||
|
vfs_setup_work_dir ();
|
||||||
|
|
||||||
|
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||||
|
|
||||||
|
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||||
|
load_codepages_list ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void test_deinit_vfs()
|
||||||
|
{
|
||||||
|
free_codepages_list ();
|
||||||
|
str_uninit_strings ();
|
||||||
|
vfs_shut ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define path_recode_one_check(input, etalon1, etalon2) {\
|
#define path_recode_one_check(input, etalon1, etalon2) {\
|
||||||
vpath = vfs_path_from_str (input);\
|
vpath = vfs_path_from_str (input);\
|
||||||
element = vfs_path_get_by_index(vpath, -1);\
|
element = vfs_path_get_by_index(vpath, -1);\
|
||||||
@ -76,25 +101,13 @@ START_TEST (test_path_recode_base_utf8)
|
|||||||
char *result;
|
char *result;
|
||||||
const vfs_path_element_t *element;
|
const vfs_path_element_t *element;
|
||||||
|
|
||||||
str_init_strings ("UTF-8");
|
test_init_vfs("UTF-8");
|
||||||
|
|
||||||
vfs_init ();
|
|
||||||
init_localfs ();
|
|
||||||
vfs_setup_work_dir ();
|
|
||||||
|
|
||||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
|
||||||
|
|
||||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
|
||||||
load_codepages_list ();
|
|
||||||
|
|
||||||
path_recode_one_check("/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", "/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", "/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ");
|
path_recode_one_check("/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", "/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", "/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ");
|
||||||
|
|
||||||
path_recode_one_check("/#enc:KOI8-R/теÑ<C2B5>товый/путь", "/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", "/#enc:KOI8-R/теÑ<C2B5>товый/путь");
|
path_recode_one_check("/#enc:KOI8-R/теÑ<C2B5>товый/путь", "/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", "/#enc:KOI8-R/теÑ<C2B5>товый/путь");
|
||||||
|
|
||||||
free_codepages_list ();
|
test_deinit_vfs();
|
||||||
str_uninit_strings ();
|
|
||||||
vfs_shut ();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@ -106,25 +119,13 @@ START_TEST (test_path_recode_base_koi8r)
|
|||||||
char *result;
|
char *result;
|
||||||
const vfs_path_element_t *element;
|
const vfs_path_element_t *element;
|
||||||
|
|
||||||
str_init_strings ("KOI8-R");
|
test_init_vfs("KOI8-R");
|
||||||
|
|
||||||
vfs_init ();
|
|
||||||
init_localfs ();
|
|
||||||
vfs_setup_work_dir ();
|
|
||||||
|
|
||||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
|
||||||
|
|
||||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
|
||||||
load_codepages_list ();
|
|
||||||
|
|
||||||
path_recode_one_check("/теÑ<C2B5>товый/путь", "/теÑ<C2B5>товый/путь", "/теÑ<C2B5>товый/путь");
|
path_recode_one_check("/теÑ<C2B5>товый/путь", "/теÑ<C2B5>товый/путь", "/теÑ<C2B5>товый/путь");
|
||||||
|
|
||||||
path_recode_one_check("/#enc:UTF-8/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", "/теÑ<C2B5>товый/путь", "/#enc:UTF-8/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ");
|
path_recode_one_check("/#enc:UTF-8/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", "/теÑ<C2B5>товый/путь", "/#enc:UTF-8/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ");
|
||||||
|
|
||||||
free_codepages_list ();
|
test_deinit_vfs();
|
||||||
str_uninit_strings ();
|
|
||||||
vfs_shut ();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@ -138,15 +139,7 @@ START_TEST(test_path_to_str_flags)
|
|||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
char *str_path;
|
char *str_path;
|
||||||
|
|
||||||
str_init_strings ("UTF-8");
|
test_init_vfs("UTF-8");
|
||||||
|
|
||||||
vfs_init ();
|
|
||||||
init_localfs ();
|
|
||||||
|
|
||||||
vfs_setup_work_dir ();
|
|
||||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
|
||||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
|
||||||
load_codepages_list ();
|
|
||||||
|
|
||||||
test_subclass1.flags = VFS_S_REMOTE;
|
test_subclass1.flags = VFS_S_REMOTE;
|
||||||
vfs_s_init_class (&vfs_test_ops1, &test_subclass1);
|
vfs_s_init_class (&vfs_test_ops1, &test_subclass1);
|
||||||
@ -197,10 +190,33 @@ START_TEST(test_path_to_str_flags)
|
|||||||
g_free (str_path);
|
g_free (str_path);
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
free_codepages_list ();
|
test_deinit_vfs();
|
||||||
str_uninit_strings ();
|
}
|
||||||
vfs_shut ();
|
END_TEST
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
START_TEST(test_encode_info_at_start)
|
||||||
|
{
|
||||||
|
vfs_path_t *vpath;
|
||||||
|
char *actual;
|
||||||
|
const vfs_path_element_t *vpath_element;
|
||||||
|
|
||||||
|
test_init_vfs("UTF-8");
|
||||||
|
|
||||||
|
vpath = vfs_path_from_str ("#enc:KOI8-R/bla-bla/some/path");
|
||||||
|
actual = vfs_path_to_str (vpath);
|
||||||
|
|
||||||
|
fail_unless (strcmp ("/#enc:KOI8-R/bla-bla/some/path", actual) == 0, "\nactual=%s\n", actual);
|
||||||
|
|
||||||
|
vpath_element = vfs_path_get_by_index (vpath, -1);
|
||||||
|
|
||||||
|
fail_unless (strcmp ("/bla-bla/some/path", vpath_element->path) == 0, "\nvpath_element->path=%s\n", vpath_element->path);
|
||||||
|
|
||||||
|
g_free (actual);
|
||||||
|
vfs_path_free (vpath);
|
||||||
|
|
||||||
|
test_deinit_vfs();
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@ -222,6 +238,7 @@ main (void)
|
|||||||
tcase_add_test (tc_core, test_path_recode_base_utf8);
|
tcase_add_test (tc_core, test_path_recode_base_utf8);
|
||||||
tcase_add_test (tc_core, test_path_recode_base_koi8r);
|
tcase_add_test (tc_core, test_path_recode_base_koi8r);
|
||||||
tcase_add_test (tc_core, test_path_to_str_flags);
|
tcase_add_test (tc_core, test_path_to_str_flags);
|
||||||
|
tcase_add_test (tc_core, test_encode_info_at_start);
|
||||||
/* *********************************** */
|
/* *********************************** */
|
||||||
|
|
||||||
suite_add_tcase (s, tc_core);
|
suite_add_tcase (s, tc_core);
|
||||||
|
Loading…
Reference in New Issue
Block a user