summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWander Lairson Costa <wander.lairson@gmail.com>2020-06-23 15:21:10 +0000
committerStefan Schmidt <s.schmidt@samsung.com>2020-07-06 10:52:54 +0200
commite797634755ae6bdd66fdf0f38273141a19da298d (patch)
tree17e57826d9e27964a0c718609d1a0d3c50d1b29d
parent2c8baa76f1c4dfaf36cc0d26cd0a979b75349f2b (diff)
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
-rw-r--r--src/lib/evil/evil_util.c2
-rw-r--r--src/tests/eina/eina_test_file.c7
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)
197 if (!path) 197 if (!path)
198 return 0; 198 return 0;
199 199
200 if (*path == '/' || *path == '\\') return 1;
201
200 length = strlen(path); 202 length = strlen(path);
201 if (length < 3) return 0; 203 if (length < 3) return 0;
202 204
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 {
547 const char *test; 547 const char *test;
548 const char *result; 548 const char *result;
549} sanitize[] = { 549} sanitize[] = {
550#ifdef _WIN32
551 { "C:\\home\\mydir\\..\\myfile", "C:/home/myfile" },
552 { "C:/home/mydir/../myfile", "C:/home/myfile" },
553 { "\\home\\mydir\\..\\myfile", "/home/myfile" },
554#endif
550 { "/home/mydir/../myfile", "/home/myfile" } 555 { "/home/mydir/../myfile", "/home/myfile" }
551}; 556};
552 557
@@ -558,7 +563,7 @@ EFL_START_TEST(eina_test_file_path)
558 for (i = 0; i < sizeof (sanitize) / sizeof (sanitize[0]); i++) 563 for (i = 0; i < sizeof (sanitize) / sizeof (sanitize[0]); i++)
559 { 564 {
560 path = eina_file_path_sanitize(sanitize[i].test); 565 path = eina_file_path_sanitize(sanitize[i].test);
561 fail_if(strcmp(path, sanitize[i].result)); 566 ck_assert_str_eq(path, sanitize[i].result);
562 free(path); 567 free(path);
563 } 568 }
564} 569}