Skip to content

Commit

Permalink
Fix #1768
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed Feb 3, 2024
1 parent 82a90a2 commit 762024b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,7 @@ inline bool is_valid_path(const std::string &path) {
auto beg = i;
while (i < path.size() && path[i] != '/') {
if (path[i] == '\0') { return false; }
else if (path[i] == '\\') { return false; }
i++;
}

Expand Down
6 changes: 6 additions & 0 deletions test/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,12 @@ TEST_F(ServerTest, GetMethodOutOfBaseDirMount2) {
EXPECT_EQ(StatusCode::NotFound_404, res->status);
}

TEST_F(ServerTest, GetMethodOutOfBaseDirMountWithBackslash) {
auto res = cli_.Get("/mount/%2e%2e%5c/www2/dir/test.html");
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::NotFound_404, res->status);
}

TEST_F(ServerTest, PostMethod303) {
auto res = cli_.Post("/1", "body", "text/plain");
ASSERT_TRUE(res);
Expand Down

0 comments on commit 762024b

Please sign in to comment.