Skip to content

Commit 762024b

Browse files
committed
Fix #1768
1 parent 82a90a2 commit 762024b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

httplib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,6 +2418,7 @@ inline bool is_valid_path(const std::string &path) {
24182418
auto beg = i;
24192419
while (i < path.size() && path[i] != '/') {
24202420
if (path[i] == '\0') { return false; }
2421+
else if (path[i] == '\\') { return false; }
24212422
i++;
24222423
}
24232424

test/test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,6 +2509,12 @@ TEST_F(ServerTest, GetMethodOutOfBaseDirMount2) {
25092509
EXPECT_EQ(StatusCode::NotFound_404, res->status);
25102510
}
25112511

2512+
TEST_F(ServerTest, GetMethodOutOfBaseDirMountWithBackslash) {
2513+
auto res = cli_.Get("/mount/%2e%2e%5c/www2/dir/test.html");
2514+
ASSERT_TRUE(res);
2515+
EXPECT_EQ(StatusCode::NotFound_404, res->status);
2516+
}
2517+
25122518
TEST_F(ServerTest, PostMethod303) {
25132519
auto res = cli_.Post("/1", "body", "text/plain");
25142520
ASSERT_TRUE(res);

0 commit comments

Comments
 (0)