Merge pull request #2718 from cesanta/pathissane

change mg_path_is_sane()
This commit is contained in:
Sergey Lyubka authored and GitHub committed 2024-04-22 20:58:02 +01:00
commit 10029d6a8d
9 files changed
+45 -33

No files matched your search

+16 -14
View File
@@ -2107,20 +2107,22 @@ static void test_str(void) {
ASSERT(strcmp(buf, "[164:2100:0:0:0:0:0:0]:3 7") == 0);
}
ASSERT(mg_path_is_sane(".") == true);
ASSERT(mg_path_is_sane("") == true);
ASSERT(mg_path_is_sane("a.b") == true);
ASSERT(mg_path_is_sane("a..b") == true);
ASSERT(mg_path_is_sane(".a") == true);
ASSERT(mg_path_is_sane(".a.") == true);
ASSERT(mg_path_is_sane("./") == true);
ASSERT(mg_path_is_sane("a..") == true);
ASSERT(mg_path_is_sane("././a..") == true);
ASSERT(mg_path_is_sane("..") == false);
ASSERT(mg_path_is_sane("../") == false);
ASSERT(mg_path_is_sane("./..") == false);
ASSERT(mg_path_is_sane("a/../") == false);
ASSERT(mg_path_is_sane("a/../b") == false);
ASSERT(mg_path_is_sane(mg_str(".")) == true);
ASSERT(mg_path_is_sane(mg_str("")) == true);
ASSERT(mg_path_is_sane(mg_str("a.b")) == true);
ASSERT(mg_path_is_sane(mg_str("a..b")) == true);
ASSERT(mg_path_is_sane(mg_str(".a")) == true);
ASSERT(mg_path_is_sane(mg_str(".a.")) == true);
ASSERT(mg_path_is_sane(mg_str("./")) == true);
ASSERT(mg_path_is_sane(mg_str("a..")) == true);
ASSERT(mg_path_is_sane(mg_str("././a..")) == true);
ASSERT(mg_path_is_sane(mg_str("..")) == false);
ASSERT(mg_path_is_sane(mg_str("../")) == false);
ASSERT(mg_path_is_sane(mg_str("./..")) == false);
ASSERT(mg_path_is_sane(mg_str("a/../")) == false);
ASSERT(mg_path_is_sane(mg_str("a/../b")) == false);
ASSERT(mg_path_is_sane(mg_str_n("a/..", 2)) == true);
ASSERT(mg_path_is_sane(mg_str_n("a/../b", 2)) == true);
}
static void fn1(struct mg_connection *c, int ev, void *ev_data) {