forked from enlightenment/efl
windows: Fix path for file sanitization
``` > c:\ > cd /windows ``` Are valid paths. Paths starting with '\' or '/' should be considered absolute paths. Reviewed-by: Vincent Torri <vincent.torri@gmail.com> Reviewed-by: João Paulo Taylor Ienczak Zanette <joao.tiz@expertisesolutions.com.br> Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Differential Revision: https://phab.enlightenment.org/D12022
This commit is contained in:
parent
2c8baa76f1
commit
e797634755
|
@ -197,6 +197,8 @@ evil_path_is_absolute(const char *path)
|
|||
if (!path)
|
||||
return 0;
|
||||
|
||||
if (*path == '/' || *path == '\\') return 1;
|
||||
|
||||
length = strlen(path);
|
||||
if (length < 3) return 0;
|
||||
|
||||
|
|
|
@ -547,6 +547,11 @@ static const struct {
|
|||
const char *test;
|
||||
const char *result;
|
||||
} sanitize[] = {
|
||||
#ifdef _WIN32
|
||||
{ "C:\\home\\mydir\\..\\myfile", "C:/home/myfile" },
|
||||
{ "C:/home/mydir/../myfile", "C:/home/myfile" },
|
||||
{ "\\home\\mydir\\..\\myfile", "/home/myfile" },
|
||||
#endif
|
||||
{ "/home/mydir/../myfile", "/home/myfile" }
|
||||
};
|
||||
|
||||
|
@ -558,7 +563,7 @@ EFL_START_TEST(eina_test_file_path)
|
|||
for (i = 0; i < sizeof (sanitize) / sizeof (sanitize[0]); i++)
|
||||
{
|
||||
path = eina_file_path_sanitize(sanitize[i].test);
|
||||
fail_if(strcmp(path, sanitize[i].result));
|
||||
ck_assert_str_eq(path, sanitize[i].result);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue