diff options
author | Wander Lairson Costa <wander.lairson@gmail.com> | 2020-06-23 15:21:10 +0000 |
---|---|---|
committer | Stefan Schmidt <s.schmidt@samsung.com> | 2020-07-06 10:52:54 +0200 |
commit | e797634755ae6bdd66fdf0f38273141a19da298d (patch) | |
tree | 17e57826d9e27964a0c718609d1a0d3c50d1b29d /src | |
parent | 2c8baa76f1c4dfaf36cc0d26cd0a979b75349f2b (diff) | |
download | efl-e797634755ae6bdd66fdf0f38273141a19da298d.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/evil/evil_util.c | 2 | ||||
-rw-r--r-- | src/tests/eina/eina_test_file.c | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/evil/evil_util.c b/src/lib/evil/evil_util.c index f7c82c4f10..19ab64ac5d 100644 --- a/src/lib/evil/evil_util.c +++ b/src/lib/evil/evil_util.c @@ -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; diff --git a/src/tests/eina/eina_test_file.c b/src/tests/eina/eina_test_file.c index bcaff19e40..fb4ff1c0df 100644 --- a/src/tests/eina/eina_test_file.c +++ b/src/tests/eina/eina_test_file.c @@ -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); } } |